How to store a string of n elements as one element of a matrix
1 回表示 (過去 30 日間)
古いコメントを表示
I have a function wich give me an array of elements like Nff=[5 0 5 0] and I want to insert Nff into a matrix N(i,j)=Nff. It can be numeric or string. It`s only important to me to store the array in the same row of the others elements 'i' and 'j' as one element of the matrix.
0 件のコメント
回答 (1 件)
Peng Li
2020 年 3 月 26 日
You may want to try a cell array instead? N{i, j} = Nff;
3 件のコメント
Peng Li
2020 年 3 月 27 日
Sorry I don't quite understand your question. It's tricky to extend a matrix this way in a loop as you add a block during one loop process to one dimension, the size changes and it conflicts with other dimension. For example, in your example above, you add four element in the first row, it's gonna stop because in this matrix pat, there are only 6 columns in the second row while you force it to have 10 elements in the first row. It's not allowed, and there is no way that you add 6 elements to the second row. They have to be consistent.
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!