# I need help please As soon as you can

2 views (last 30 days)
Mahdi Almahuzi on 9 Apr 2020
Commented: Walter Roberson on 14 Apr 2020
I try to run this code to solve an n x n linear
system using the Gaussian Elimination Methods
but it says there is error in Error: File: mad.m Line: 7 Column: 20
Illegal use of reserved keyword "for".
can anybody solve the problem and send the code?
for i=j+1:m
a(i,:)=a(i,:)-a(j,:)*(a(i,j)/a(j,j));
enda = input('Enter the augument matrix:');
[m,n]=size(a);
for j=1:m-1
for z=2:m
if a(j,j)==for i=j+1:m
a(i,:)=a(i,:)-a(j,:)*(a(i,j)/a(j,j));
enda = input('Enter the augument matrix:');
[m,n]=size(a);
0;
t=a(j,:);a(j,:)=a(z,:);
a(z,:)=t;
end
end
end
end
end
x=zeros(1,m);
for s=m:-1:1
c=0;
for k=2:m
c=c+a(s,k)*x(k);
end
x(s)=(a(s,n)-c)/a(s,s);
end
disp('Gauss elimination method:');
a;
x';

Mohammad Sami on 9 Apr 2020
What were you trying to do at this line. This is where the error is likely coming from due to incorrect usage of for loop.
if a(j,j)==for i=j+1:m
Rik on 9 Apr 2020
You should select your code and click the smart allign button (by default the hotkey for this is ctrl-i). Then it is easier to see the structure of your code and find errors/mismatches with end keywords.
Your question is not urgent, the reason for that is explained here. You should try to use a descriptive title instead.
Walter Roberson on 14 Apr 2020
There is no rule against posting assignment questions here.
The regular volunteers make attempts to guide people to understand the situation better, avoiding giving direct solutions for anything non-trivial.

Vinai Datta Thatiparthi on 12 Apr 2020
To echo with what's already mentioned on this thread, "for" is a reserved keyword in MATLAB, we cannot use this as another variable. You might have to rearrange your code accordingly to avoid the error.