Error using vertcat Dimensions of arrays being concatenated are not consistent.
1 次查看(过去 30 天)
显示 更早的评论
I want to make the results for each iteration to display not just the final answer. where the first column is the iteration number and the second column is the result of each iteration.
RRTSS is a called file with an output of " ans = [ t1 dist Reach ] "
size is another variable that contain output.
but the error came out. can anyone help me ??
Ni=2
T = [];
for iteration=1:Ni
RRTSS1
T = [T; iteration size ans] ;
end
T
output :
Error using vertcat Dimensions of arrays being concatenated are not consistent.
7 个评论
Jan
2019-11-20
编辑:Jan
2019-11-20
Do not overload important Matlab commands, because this must end in confusions. "size", "Inf", "ans", "path".
Which line is cause the error?
We cannot run your code due to the missing script "simple1ColDec".
Using l as name of a variable provokes the confusion with 1. Using one command per line is recommended also.
回答(1 个)
Ridwan Alam
2019-11-20
编辑:Ridwan Alam
2019-11-20
In the RRTSS1 script, "dist" is defined inside an "if" statement without any "else" for "dist" value.
So if Reach=0, then ans = [t1 [] Reach] which is not 3x1, rather a 2x1 vector.
This is causing the dimension mismatch.
if Reach==1
G=sparse(CON);
[dist, path]=graphshortestpath(G, 1, size+1); l=length(path);
for i=1:l-1
plot3([N(1,path(i)) N(1,path(i+1))], [N(2,path(i)) ...
N(2,path(i+1))], [N(3,path(i)) N(3,path(i+1))],'k','linewidth',3);
end
else
dist = 0;
end
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!