0% found this document useful (0 votes)
32 views2 pages

'Long' 'G': Matlab Code

The MATLAB code uses a while loop to iteratively calculate values of x1, x2, and x3. It calculates the error between successive iterations and repeats until the error of x1 is less than 0.01. The results show the final values and errors of x1, x2, and x3.

Uploaded by

Ja123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

'Long' 'G': Matlab Code

The MATLAB code uses a while loop to iteratively calculate values of x1, x2, and x3. It calculates the error between successive iterations and repeats until the error of x1 is less than 0.01. The results show the final values and errors of x1, x2, and x3.

Uploaded by

Ja123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MATLAB CODE

clear;
clc;
format('long','g');
i=1;
x2(i)=0;
x3(i)=0;
error_x1(i)=9999;

while error_x1(i)>=0.01
x1(i+1)=((1.057*10^-4)+2860*x2(i)-24*x3(i))/(7.26*10^5);
x2(i+1)=((-1.04162*10^-2)+2860*x1(i)-(7.26*10^5)*x3(i))/(-
1.86472*10^8);
x3(i+1)=(2.56799+(1.86472*10^8)*x1(i)-(7.26*10^5)*x2(i))/
(5.24357*10^10);

error_x1(i+1)=abs((x1(i+1)-x1(i))/x1(i+1))*100;
error_x2(i+1)=abs((x2(i+1)-x2(i))/x2(i+1))*100;
error_x3(i+1)=abs((x3(i+1)-x3(i))/x3(i+1))*100;

i=i+1;
end

disp(' x1 error(%)');
disp([x1',error_x1'])
disp(' x2 error(%)');
disp([x2',error_x2'])
disp(' x3 error(%)');
disp([x3',error_x3'])
MATLAB RESULTS

x1 error(%)

0 9999

1.45592286501377e-10 100

1.45810719408909e-10 0.149805795086316

1.45811444658023e-10 0.000497388333113759

x2 error(%)

0 0

5.58593247243554e-11 100

5.60477647359023e-11 0.336213250313878

5.60497741767943e-11 0.00358510078147236

x3 error(%)

0 0

4.89740768217073e-11 100

4.94910591634847e-11 1.04459744955063

4.94918333462206e-11 0.00156426360382677

You might also like