Nested for loops - FOR expression comma separated list Error

1 次查看(过去 30 天)
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.

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by