Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Updating a matrix using a for loop and if clause. Causing expression to the left of the equals sign is not a valid target for an assignment.
1 回表示 (過去 30 日間)
古いコメントを表示
Hi all,
I'm trying to update a matrix so that values increment when another value is present in another dataset. However it seems that data(1,i) is not a valid target for an assignment. I can't seem to find out why. Any help is much appreciated.
xinc = 0.03125;
yinc = 0.015625;
zinc = 0.03125;
xnew = 0.5;
ynew = 0.25;
znew = 0.5;
data = zeros(3,5000);
for i = 1:1:5000
if(Seed0Orange(251,i) == 100);
{
data(i,1) = xnew;
xnew = xinc + xnew;
data(i,2) = ynew;
ynew = ynew + xinc;
data(i,3) = znew;
znew = znew + zinc;
}
end
end
0 件のコメント
回答 (2 件)
Iain
2014 年 8 月 13 日
The problem is that you have included
{ and } around the code. Remove those and it'll work.
0 件のコメント
Andrei Bobrov
2014 年 8 月 13 日
add = [0.03125,0.015625,0.03125];
d1 = [0.5,0.25,0.5];
t = Seed0Orange == 100;
n = nnz(t);
data = zeros(3,5000);
data(t,:) = cumsum([d1;ones(n-1,1)*add]);
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!