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"

 Accepted Answer

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

More Answers (0)

Categories

Tags

Asked:

on 10 Sep 2018

Commented:

on 10 Sep 2018

Community Treasure Hunt

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

Start Hunting!