Problem with assigning a vector to a matrix
Mostrar comentarios más antiguos
Hi Matlab-Community,
i have a problem with assigning a vector to a matrix. As you can see in the picture i want to assign a vector to a row "i" of a matrix. Each step of the loop i created calculates a new vector. However the vector becomes smaller after every loop because the variables become smaller. I hope you can help my with my issue.
Best regards

1 comentario
Mathieu NOE
el 12 de En. de 2021
hello
either you work with cell arrays , which can help you solve this variable dimensions vector issue, or if you stick to work with regular arrays (double / strings) , you have to initialize the SigR matrix with the max dimensions it is supposed to reach , then index the second dimensions based on the right hand side vector size , in other words :
[mm,nn] = size(out.SigR.sigR);
SigR(i,1:nn) = out.SigR.sigR; % only columns 1 to nn are poulated with RHS vector values
% SigR was initialized with more columns than nn, the trailing values are zero or nan,
% - depending how you initialized SigR
Respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!