SyntaxError: Unexpected "for" in my matlab code

Good morning, I have an error message in my matlab code but I can't find where, it looks simple and all the variables are in their place I don't understand. Can you help me?
[m,i] = max(Natoms(4,:));
[m,j] = max(Natoms(4,:));
[m,k] = max(Natoms(4,:));
Natoms(4,:) = Natoms(4,:).*0;
Natoms(5,:) = Natoms(5,:).*0;
Natoms(6,:) = Natoms(6,:).*0;
d = [sqrt(D(1)*t) sqrt(D(2)*t) sqrt(D(3)*t);
m = [level(i) level(j) level(k)];
for kk = [1:Ni]
levelnb = [1];
if ion(kk,1) > 0
type = ion(kk,5);
xx = m(type) + erfinv(2*rand-1)*2*d(type);
ion(kk,1) = ion(kk,1) + xx;
x = ion(kk,1);
[levelnb] = new_level(x,levelnb,1,level,L,dx);
if levelnb(1) < L+1
Natoms(3+type,levelnb(1)) = Natoms(3+type,levelnb(1)) + 1;
end
end
end
File "diffusionf.m", line 52
for kk = [1:Ni]
^
SyntaxError: Unexpected "for"

 採用された回答

Steven Lord
Steven Lord 2018 年 9 月 10 日

0 投票

On the line where you define the variable d you have an opening square bracket but no corresponding closing square bracket.

1 件のコメント

Tim Nemo
Tim Nemo 2018 年 9 月 10 日
Thank you very much !! :D

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEntering Commands についてさらに検索

タグ

質問済み:

2018 年 9 月 10 日

コメント済み:

2018 年 9 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by