(adsbygoogle = window.adsbygoogle || []).push({}); Help with Matlab!!!

Hi,

I've just started learning how to use the Matlab and came across this question in the textbook:

Consider the following system of equations:

[-1 2 4 1 0]

[ 5 4 0 0 0]

[ 0 6 1 0 4] x =

[ 0 -1 0 -1 4]

[ 1 0 -2 -5 1]

[ 1 ]

[ 1 ]

[ 1 ]

[ 1 ]

[ 1 ]

Write a Matlab script file, using the Matlab function gauss seidel that:

(a) Sets up the matrix and the vector in the system of equations

(b) Applies 5 iterations of the gauss seidel method using x(0)=[0,0,0,0,0]T

Now I know how to part (b) but can't seem to get my head around part (a). I have attached a copy of the gauss seidel function I wrote. I know for part (b) I have to put in the values of the inputs: A,b,y,N and then simply execute the function. I really don't know how to solve part (a). Help Please!!!

Edit to say: I honestly don't really understand part (a) of the question. If they are simply asking me to write up the matrix and the vector to calculate the x vector then I know how to do that but I don't know if the question is asking me to actually set it up as x1+x2+x3+...=some no.

If so, do I simply create an M-file like the one below???

A=[-1 2 4 1 0;5 4 0 0 0;0 6 1 0 4;0 -1 0 -1 4;1 0 -2 -5 1]

b=[1;1;1;1;1]

x = A\b

Gauss Seidel function:

function x = gs (A,b,y,N)

n = length(y);

x = y;

for k=1:N

for i=1:n

sum = b(i);

for j=1:i-1

sum = sum - A(i,j)*x(j);

end

for j = i+1:n

sum = sum - A(i,j)*y(j);

end

x(i) = sum/A(i,i);

end

y = x';

end

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Help with Matlab

Loading...

Similar Threads - Help Matlab | Date |
---|---|

Matlab MATLab: Not enough inputs for nlinfit | Nov 16, 2017 |

Matlab Help needed to fix a matlab code | Nov 8, 2017 |

New to Matlab, help with vectors | Feb 20, 2016 |

Need help with integral | Dec 23, 2015 |

Communication between Arduino and Matlab Help | Jun 19, 2015 |

**Physics Forums - The Fusion of Science and Community**