Same loop have different vector output
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Chaudhary P Patel
el 13 de Abr. de 2022
Comentada: Chaudhary P Patel
el 15 de Abr. de 2022
Sir, when i am running this loop for f_s the first f_s1 is comming as a column vector while f_s2, 3, 4, 5, are comming as a row vector.
Please sir, suggest me where i amking the mistakes.
utdelt=([1;2;3;4;5;6;7;8;9;10;11;12;13;14;15]);
Ktts=rand(6,6);
for i=1:1:10
for n=1:1:5
if n==1
Utdelt=([zeros(3,1); (utdelt(1:3,i))]);
eval(['Utdelt',num2str(n),'=[zeros(3,1); (utdelt(1:3,i))]']);
else
Utdelt=utdelt([((1+(n-2)*3):(6+(n-2)*3)),i]);
eval(['Utdelt',num2str(n),'=[utdelt((1+(n-2)*3):(6+(n-2)*3,i)]']);
end
eval(['Ktts',num2str(n),'l']);
eval(['f_s',num2str(n),'=Ktts*Utdelt']);
end
end
4 comentarios
Stephen23
el 13 de Abr. de 2022
Editada: Stephen23
el 13 de Abr. de 2022
"Please sir, suggest me where i amking the mistakes."
The obvious mistake is that you are forcing meta-data into variable names.
That forces you into writing slow, complex, inefficient, obfuscated, buggy code that is hard to debug (which is exactly what your question demonstrates, and hopefully you are about to start to notice).
Respuesta aceptada
Walter Roberson
el 13 de Abr. de 2022
7 comentarios
Walter Roberson
el 14 de Abr. de 2022
When you do not post actual code, then we cannot give you actual answers.
For the code that you posted the bug is that Ktts1l is not defined.
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!