Nested for loops - FOR expression comma separated list Error

1 Ansicht (letzte 30 Tage)
Del
Del am 24 Mär. 2014
Beantwortet: Matt J am 24 Mär. 2014
When I try to run this code:
A = zeros(30000, NV);
counter = 1;
for k = 1:P
for n = GN(:,k)
for i = AT{n}
A(counter, pMap(i,1,1)) = - w(i,k);
end
counter = counter + 1;
end
end
I am getting this error: "FOR expression comma separated list must have exactly one item".
I am not sure what is going on.
NV is some number like 7000.
GN is a matrix of the form
[1 2 3;
2 3 4;
3 4 5]
AT is a cell array where its entries are arrays of the form:
AT{1} = [1 2 3 4 5 6 7 8 9 10];
AT{2} = [11 12 13 14 15 16 17 18 19 20]; etc...
Any help would be appreciated.

Antworten (1)

Matt J
Matt J am 24 Mär. 2014
for n = GN(:,k).' %<-- note transpose

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by