Hi, I have the following 1x10 matlab structure where all 10 elements are column vectors of varying sizes. Need to convert it to matrix as described below. Any help?
5 ビュー (過去 30 日間)
古いコメントを表示
I have the following 1x10 matlab structure where all 10 elements are column vectors of varying length. I want to populate the first 10 row of a matrix of zeros of size 256x160 with this structure such that first 10 rows of the matrix are replaced by 10 column vectors values respectively. If length does not cover all 160 values it will stay 0 as before. Could you kindly
help? Thank you so much.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1132105/image.png)
![output](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1132100/output.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1132105/image.png)
採用された回答
Voss
2022 年 9 月 21 日
If S is your struct array and M is your matrix of zeros:
for ii = 1:numel(S)
M(ii,1:numel(S(ii).times)) = S(ii).times;
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!