Содержание
- Error using surf (line 71) Data dimensions must agree.. How to rectify this error.
- Direct link to this question
- Direct link to this question
- Answers (1)
- Direct link to this answer
- Direct link to this answer
- See Also
- Categories
- Products
- Release
- Community Treasure Hunt
- How to Get Best Site Performance
- Americas
- Europe
- Asia Pacific
- Data dimensions must agree error
- Direct link to this question
- Direct link to this question
- Direct link to this comment
- Direct link to this comment
- Direct link to this comment
- Direct link to this comment
- Answers (1)
- Direct link to this answer
- Direct link to this answer
- See Also
- Categories
- Community Treasure Hunt
- How to Get Best Site Performance
- Americas
- Europe
- Asia Pacific
- While running this program I got the error «Error using mesh (line 71) Data dimensions must agree»
- Direct link to this question
- Direct link to this question
- Answers (1)
- Direct link to this answer
- Direct link to this answer
- See Also
- Categories
- Community Treasure Hunt
- How to Get Best Site Performance
- Americas
- Europe
- Asia Pacific
- Surf dimensions do not agree. Help!
- Direct link to this question
- Direct link to this question
- Answers (1)
- Direct link to this answer
- Direct link to this answer
- Direct link to this comment
- Direct link to this comment
- Direct link to this comment
- Direct link to this comment
- See Also
- Categories
- Community Treasure Hunt
- How to Get Best Site Performance
- Americas
- Europe
- Asia Pacific
- While running this program I got the error «Error using mesh (line 71) Data dimensions must agree»
- Direct link to this question
- Direct link to this question
- Answers (1)
- Direct link to this answer
- Direct link to this answer
- See Also
- Categories
- Community Treasure Hunt
- How to Get Best Site Performance
- Americas
- Europe
- Asia Pacific
Error using surf (line 71) Data dimensions must agree.. How to rectify this error.
Direct link to this question
Direct link to this question
0 Comments
Answers (1)
Direct link to this answer
Direct link to this answer
0 Comments
See Also
Categories
Products
Release
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Читайте также: Unarc dll вернул код ошибки 6 error file read operation failed что делать
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 简体中文 Chinese
- English
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Accelerating the pace of engineering and science
MathWorks is the leading developer of mathematical computing software for engineers and scientists.
Источник
Data dimensions must agree error
Direct link to this question
Direct link to this question
2 Comments
Direct link to this comment
Direct link to this comment
Direct link to this comment
Direct link to this comment
Answers (1)
Direct link to this answer
Direct link to this answer
0 Comments
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 简体中文 Chinese
- English
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Читайте также: Assistant ap 105 прошивка
Accelerating the pace of engineering and science
MathWorks is the leading developer of mathematical computing software for engineers and scientists.
Источник
While running this program I got the error «Error using mesh (line 71) Data dimensions must agree»
Direct link to this question
Direct link to this question
0 Comments
Answers (1)
Direct link to this answer
Direct link to this answer
0 Comments
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 简体中文 Chinese
- English
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Accelerating the pace of engineering and science
MathWorks is the leading developer of mathematical computing software for engineers and scientists.
Источник
Surf dimensions do not agree. Help!
Direct link to this question
Direct link to this question
0 Comments
Answers (1)
Direct link to this answer
Direct link to this answer
2 Comments
Direct link to this comment
Direct link to this comment
Direct link to this comment
Direct link to this comment
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
Читайте также: Bravis nb106 3g прошивка
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 简体中文 Chinese
- English
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Accelerating the pace of engineering and science
MathWorks is the leading developer of mathematical computing software for engineers and scientists.
Источник
While running this program I got the error «Error using mesh (line 71) Data dimensions must agree»
Direct link to this question
Direct link to this question
0 Comments
Answers (1)
Direct link to this answer
Direct link to this answer
0 Comments
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 简体中文 Chinese
- English
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Accelerating the pace of engineering and science
MathWorks is the leading developer of mathematical computing software for engineers and scientists.
Источник
Hozra 0 / 0 / 0 Регистрация: 02.08.2013 Сообщений: 5 |
||||||||||||
1 |
||||||||||||
02.08.2013, 17:01. Показов 5803. Ответов 8 Метки нет (Все метки)
Здравствуйте. Пытаюсь построить 3-D график (2-D строится нормально). Выскакивает ошибка:
Ничего криминального в 6й строке не нашел. Ошибка вылетает, когда на эту часть умножаю
Почему при этом умножении выскакивает ошибка непонятно. Ведь в скобках нет перемножения векторов. Рабочий код:
__________________
0 |
lomt 453 / 279 / 13 Регистрация: 13.11.2012 Сообщений: 588 Записей в блоге: 1 |
||||
02.08.2013, 17:24 |
2 |
|||
Криминальность в том, что в строчке
Размерность левой части 1х11, а правой 1х501, поэтому их никак не перемножить между собой.
0 |
0 / 0 / 0 Регистрация: 02.08.2013 Сообщений: 5 |
|
02.08.2013, 17:28 [ТС] |
3 |
lomt
0 |
0 / 0 / 0 Регистрация: 02.08.2013 Сообщений: 5 |
|
02.08.2013, 17:33 [ТС] |
4 |
Сделал размерности одинаковыми, не работает
0 |
Зосима 5210 / 3542 / 370 Регистрация: 02.04.2012 Сообщений: 6,455 Записей в блоге: 17 |
||||||||||||
02.08.2013, 19:22 |
5 |
|||||||||||
lomt, нужно матричную магию приметить: вектор-столбец умножаемый на вектор-строку (разных размеров) дает в результате матрицу, НО нужно чтобы вначале был столбец , а после знака «умножить» — строка ! Никак иначе! это матричное умножение, от перестановки меняется всё!
Добавлено через 9 минут
Считает все, но в рисовалке что-то явно напутал.
1 |
0 / 0 / 0 Регистрация: 02.08.2013 Сообщений: 5 |
|
02.08.2013, 19:47 [ТС] |
6 |
Зосима Спасибо, все работает Что значит Но вообще такие штуки делаются через meshgrid ? Можно ли сделать так, чтобы все кривые были соединены между собой, .т.е. получился бы этакий плавный переход.
0 |
5210 / 3542 / 370 Регистрация: 02.04.2012 Сообщений: 6,455 Записей в блоге: 17 |
|
02.08.2013, 20:08 |
7 |
Что значит:Но вообще такие штуки делаются через meshgrid Это типичный прием при построении функции двух преременных в матлаб
Можно ли сделать так, чтобы все кривые были соединены между собой, .т.е. получился бы этакий плавный переход. Тут тебе должна помочь функции mesh или surf:
0 |
Hozra 0 / 0 / 0 Регистрация: 02.08.2013 Сообщений: 5 |
||||||||
04.08.2013, 22:32 [ТС] |
8 |
|||||||
Зосима Все понял, второй подход мне понравился Добавлено через 4 часа 18 минут
Ошибка:
Когда я выравниваю размерности h и psi, тогда ошибка исчезает, но график при этом строится некорректно. До этого проблем с размерностями не было. В чем может быть проблема?
0 |
5210 / 3542 / 370 Регистрация: 02.04.2012 Сообщений: 6,455 Записей в блоге: 17 |
|
04.08.2013, 22:52 |
9 |
Точку перед делением в строке 17 не забыл? Забыл!
0 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
04.08.2013, 22:52 |
Помогаю со студенческими работами здесь Ошибка при построении графика Ошибка при построении графика Ошибка при построении графика Ошибка при построении графика функции Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 9 |
In this Insight, I’ll go over 5 common MATLAB error messages, what they mean, and how to fix them. Hopefully, after reading this post you’ll find yourself being more productive, and maybe even help your friends with their code.
Most forums online where people post MATLAB questions generate quite a bit of duplicates, and PhysicsForums is no exception. The fact is, there are just certain situations that come up constantly in MATLAB, and if you’re a newer user, don’t consider yourself a programmer, or haven’t used the software in a while, then you’re likely to get tripped up and receive one of those red error messages. It can be especially frustrating when the message doesn’t make sense to you, or your best efforts to fix it come up dry.
Table of Contents
1
1. Error using * Inner matrix dimensions must agree.
By far the most common error message I see posted about by new users is this one. They create a few matrices or vectors and just go to multiply them with A*B, and this message is returned. Some example code that produces this message is:
A = [1 2 3]; B = [4 5 6]; A*B Error using * Inner matrix dimensions must agree.
The key to this error message is usually that people are not aware of the elementwise operators in MATLAB. The * operator performs matrix multiplication, where an NxM matrix is multiplied by an MxP matrix, resulting in an NxP matrix. Notice how those matrices have the common dimension “M”? That’s where this message comes from; it’s a common inner dimension.
Most often, you simply need to use .* instead of * to perform the elementwise multiplication, where corresponding elements are multiplied and the result is the same size as the inputs.
A.*B ans = 4 10 18
For more information about the different MATLAB operators, see Array vs. Matrix Operations. Note that even though this error message is the most common in this situation (since, well, multiplication is pretty popular) there are similar messages for the misuse of ^, /, and as opposed to .^, ./, and ..
2. Index exceeds matrix dimensions.
Quite simply, this error arises when you try to reference an element that doesn’t exist. For example, if the matrix has N elements, and you try to index into the N+1 element:
A = magic(5)
A =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
A(26)
Index exceeds matrix dimensions.
To fix this error, double-check that the matrix is the size you were expecting it to be and that the index you’re using is also what you expect. For example, if the index is the result of a calculation or is part of a loop, then you might need to adjust the calculation of the number of loop iterations. Some useful functions to check sizes and number of elements are numel(), size(), and length().
3. Subscript indices must either be real positive integers or logicals.
The most common reason this message arises is that people come to MATLAB from other programming languages and can’t get used to the fact that MATLAB indexing begins at 1. A(1) is the first element in a vector or matrix (or equivalently A(1,1)), not A(0) like in other programming languages!
A = magic(3)
A =
8 1 6
3 5 7
4 9 2
A(0)
Subscript indices must either be real positive integers or logicals.
There are a number of theories for why MATLAB uses 1-based indexing, but ultimately the answer is pretty simple. 1-based indexing is the language of Mathematics, as confirmed by Cleve Moler himself in a comment on this April Fools blog post.
We have always had BOTH 0-based indexing and 1-based indexing. In order to distinguish between the two, 0-based indices are followed by “+1″. The 1-based indices are preferred becaused they are the language of mathematics. — Cleve
I won’t expound on this anymore, but suffice it to say if you’re interested in this, a quick google search will turn up bountiful results, as it has a long and contentious history!
This error message can also arise if you use a noninteger (or negative) value to index. What is MATLAB supposed to do with A(1.5) or A(-3)? In this context, it’s again likely that you’ll want to check the bounds of any loop statements in your code to make sure they aren’t producing decimal or negative values for indexing.
4. The expression to the left of the equals sign is not a valid target for an assignment.
This error message arises because of misuse of the = and == operators. The = operator does an assignment, and the == operator does a logical test for equality. In the context of an if statement, for example, the if operator is expecting to see a logical condition to determine whether to continue executing code. So the following example code produces this error:
n = 5;
if n = 4
n = n.^2;
end
if n = 4
|
Error: The expression to the left of the equals sign is not a valid target for an assignment.
To fix this all you need to do is use == instead:
n = 5; if n == 4 n = n.^2; end
This code outlines the differences between the two operators more clearly:
A = 1:5 A = 1 2 3 4 5 B = 5; A == B ans = 0 0 0 0 1 C = A == B C = 0 0 0 0 1
In short: when you need to compare values, use ==. When you want to assign a value, use =.
5. Subscripted assignment dimension mismatch.
This error message arises because of an attempt to assign a vector or matrix into a compartment that it does not fit in. The dimension of the subscripted elements does not match the dimension of the assignment. For example, you cannot assign the first element in a matrix to be a vector, because there is only room for 1 element:
A = magic(3)
A =
8 1 6
3 5 7
4 9 2
A(1) = [4 5 6]
Subscripted assignment dimension mismatch.
This error can be much more subtle when you’re working with large matrices or loops, and it can occur because of a mismatch on either side of the equals sign. Sometimes the size of a vector or matrix can grow in an unexpected way in a loop, and you’ll receive this message and wonder what went wrong. The best way to debug this error is to double-check that all of your assignments are the sizes you expect them to be and that your matrices are growing (or not) as you expect them to.
If you don’t have any loops, just break the statement apart and check the size of each side. You won’t get this error if the sizes match exactly:
size(A(1:3)) ans = 1 3 size([4 5 6]) ans = 1 3 A(1:3) = [4 5 6] A = 4 1 6 5 5 7 6 9 2
Feedback
Obviously, I could go on with another 25 error messages, but I think these are the most common ones I see people posting about. If you’re interested in reading about some others, check out this link:
http://en.wikibooks.org/wiki/MATLAB_Programming/Error_Messages
Post about your favorite or least favorite MATLAB error messages in the comments, and let me know what you think!
Disclaimer: All views and/or opinions expressed in this post are my own, and should not be interpreted in any other way.
Josh received a BA in Physics from Clark University in 2009, and an MS in Physics from SUNY Albany in 2012. He currently works as a technical writer for MathWorks, where he writes documentation for MATLAB.