Parse Error in funtion

4 views (last 30 days)
Sanjoy Dey
Sanjoy Dey on 3 Apr 2019
Answered: Bjorn Gustavsson on 3 Apr 2019
p=0;
for k=0:5
if(c(k)~= t)
continue;
else
position=k;
value=a(position);
swap(p++) = value;
user(k++)=position;
max=swap(0);
end
end
m=0;
while(m<j)
if(max<swap(m))
max=swap(m);
m=m+1;
end
end
Showing parse error in two line swap(p++)=value and user(k++)=position.
Give me a sloution for this error.

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 3 Apr 2019
Simples,
k++
is not valid matlab syntax, sadly according to some, but fact. You'll have to do an excplicit incrementations:
k = k+1;
p = p+1;
inside your else clause.
HTH

More Answers (0)

Community Treasure Hunt

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

Start Hunting!