I don't receive the error message I'm supposed to
1 回表示 (過去 30 日間)
古いコメントを表示
My textbook says "there must always be the same number of values in each row and each column of a matrix"
They give this as an example of proper code:
>>mat=[431;256]
mat=
4 3 1
2 5 6
And this as an example of improper code:
>>mat=[357;12]
It says I should be getting an error that says "dimensions of arrays being concatenated are not consistent", but I don't get this error, instead MATLAB registers the code as:
mat=
123
12
Does anyone know what goes on here? Thanks in advance!
1 件のコメント
Walter Roberson
2020 年 9 月 20 日
Somehow you are missing spaces.
>> mat=[431;256]
mat =
431
256
>> mat=[4 3 1;2 5 6]
mat =
4 3 1
2 5 6
採用された回答
その他の回答 (1 件)
Image Analyst
2020 年 9 月 20 日
That code is perfectly fine. Perhaps the bad code is
mat=[3,5,7;1,2] % Preferred - commas between
or
mat = [3 5 7; 1 2] % Not preferred - spaced between Might get orange warning squiggles.
In those cases there would be 3 columns in the first row and 2 columns in the second row, which is not allowed.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Numeric Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!