Error using vertcat Dimensions of arrays being concatenated are not consistent.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Jan
am 20 Nov. 2019
Bearbeitet: Jan
am 20 Nov. 2019
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.
Antworten (1)
Ridwan Alam
am 20 Nov. 2019
Bearbeitet: Ridwan Alam
am 20 Nov. 2019
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 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!