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 Comment

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

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 12 Jan 2021

Commented:

on 12 Jan 2021

Community Treasure Hunt

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

Start Hunting!