Problem with assigning a vector to a matrix
Ältere Kommentare anzeigen
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 Kommentar
Mathieu NOE
am 12 Jan. 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
Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!