Error using vertcat Dimensions of arrays being concatenated are not consistent.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Jan
le 20 Nov 2019
Modifié(e) : Jan
le 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.
Réponses (1)
Ridwan Alam
le 20 Nov 2019
Modifié(e) : Ridwan Alam
le 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 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!