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 个评论
Mathieu NOE
2021-1-12
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
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!