How to add a cell array inside another cell array in a nested for loop?

Hello everyone.
I would like to know how I could make this one. I`m trying this:
for i=1:sets
for j = 1:n_disc
x_r = A{i}*(data{i}(j,:)');
X_r{1,i}(1,j) = {[x_r]};
end
end
But I get this error:
Index in position 1 exceeds array bounds (must not exceed 53).
How could I make this work?

7 件のコメント

Sindar
Sindar 2020 年 9 月 25 日
編集済み: Sindar 2020 年 9 月 25 日
sounds like data or A aren't the size you think.
Also, x_r will be a numeric array here, not a cell
Omar Andrés Rosada González
Omar Andrés Rosada González 2020 年 9 月 25 日
Hi Sindar, that's the point, I think. A is a 3x3 matrix inside a cell, data is a nx3 matrix inside another cell, x_r it would be a vector 1x3.
That x_r is what I would like to save in another cell call X_r. I don't know how to do it.
KSSV
KSSV 2020 年 9 月 25 日
You have not mentioned the line number of error. Dimensions of the data is not known.
Try using. X_r{i} instead of X_r{1,i}.
Omar Andrés Rosada González
Omar Andrés Rosada González 2020 年 9 月 25 日
Thanks for your help, but I'm still having the same error.
Sudhakar Shinde
Sudhakar Shinde 2020 年 9 月 25 日
Can you share sets, n_disc, data and A.
Mohammad Sami
Mohammad Sami 2020 年 9 月 25 日
What is the size of A and data and contents in data{i}
Sourabh Kondapaka
Sourabh Kondapaka 2020 年 11 月 2 日
Can you share the variables that are being used in your code as a .mat file ?
To save variables in workspace to a .mat file, refer this link

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で MATLAB についてさらに検索

製品

リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by