Problem with assigning a vector to a matrix

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 commentaire

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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Commenté :

le 12 Jan 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by