Error using vertcat Dimensions of arrays being concatenated are not consistent.
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Jan
el 20 de Nov. de 2019
Editada: Jan
el 20 de Nov. de 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.
Respuestas (1)
Ridwan Alam
el 20 de Nov. de 2019
Editada: Ridwan Alam
el 20 de Nov. de 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 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!