How to solve 'Error using vertcat, Dimensions of arrays being concatenated are not consistent.'? But they have the same dimensions.
1 回表示 (過去 30 日間)
古いコメントを表示
Hi Everyone,
This error occurs whenever I have changed a value in my table to 0 or above 10. Whenever I have values between 1 and 9 the code works. What could be the reason for this and any suggestion on how can I make it work for 0?
Thanks,
採用された回答
Walter Roberson
2020 年 4 月 22 日
M1_6_A1 = [ 0 0 0 ];
if t1(1,1) == 0
elseif t1(1,1) == 1
M1_6_A1 = [ 0 0 1 ];
elseif t1(1,1) == 2
M1_6_A1 = [ 0.1 0.5 0.8 ];
elseif t1(1,1) == 3
M1_6_A1 = [ 0 0.9 1 ];
elseif t1(1,1) == 4
M1_6_A1 = [ 0.2 0.8 0.8 ];
elseif t1(1,1) == 5
M1_6_A1 = [ 0.2 0.8 0.3 ];
elseif t1(1,1) == 6
M1_6_A1 = [ 0.7 0.9 0.2 ];
elseif t1(1,1) == 7
M1_6_A1 = [ 0.9 1 0 ];
elseif t1(1,1) == 8
M1_6_A1 = [ 0.9 0.5 0 ];
elseif t1(1,1) == 9
M1_6_A1 = [ 1 0 0 ];
else
M1_6_A1 = [ 1 1 1 ];
end
No for loop needed.
You could rewrite as
if t1(1,1) == 0
M1_6_A1 = [ 0 0 0 ];
elseif t1(1,1) == 1
M1_6_A1 = [ 0 0 1 ];
elseif t1(1,1) == 2
M1_6_A1 = [ 0.1 0.5 0.8 ];
elseif t1(1,1) == 3
M1_6_A1 = [ 0 0.9 1 ];
elseif t1(1,1) == 4
M1_6_A1 = [ 0.2 0.8 0.8 ];
elseif t1(1,1) == 5
M1_6_A1 = [ 0.2 0.8 0.3 ];
elseif t1(1,1) == 6
M1_6_A1 = [ 0.7 0.9 0.2 ];
elseif t1(1,1) == 7
M1_6_A1 = [ 0.9 1 0 ];
elseif t1(1,1) == 8
M1_6_A1 = [ 0.9 0.5 0 ];
elseif t1(1,1) == 9
M1_6_A1 = [ 1 0 0 ];
else
M1_6_A1 = [ 1 1 1 ];
end
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!