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

1 ビュー (過去 30 日間)
Omar Andrés Rosada González
Omar Andrés Rosada González 2020 年 9 月 25 日
回答済み: Jalaj Gambhir 2020 年 9 月 28 日
Hello everyone.
I'm trying to make something like this:
for i=1:sets
for j = 1:n_disc
x_r = A{i}*(datos{i}(j,:)');
X_r{1,i}(1,j) = {[x_r]};
But I have this error message:
Index in position 1 exceeds array bounds (must not exceed 53).
How could I make this work?
Thanks for your help.

回答 (1 件)

Jalaj Gambhir
Jalaj Gambhir 2020 年 9 月 28 日
As you have not mentioned what the variables exactly are, it is not easy to figure out the issue. Though, it looks like i/j are having values which are exceeding the array bounds of either datos or A or X_r. You can check out their sizes by debugging using breakpoints. To know more about multilevel indexing in cell arrays have a look here.
Hope this helps!


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




Community Treasure Hunt

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

Start Hunting!

Translated by