# 2 returns in matlab function

• Feb 27th 2010, 10:38 AM
freddyjones39
2 returns in matlab function
I am writing two function, one to solve a system of nonlinear equations using jacobi's method, and one to find the most efficient relaxation it. My problem is that I want to pass two values from the first code (jacobi) to the second code (plotter), But I can only figure out how to send on. I would really appreciate any help. Here is the first pare of my Jacobi code (requires 4 input) and my plotter code:

re=10^(-3); %Relative Error Tolerance
rt=10^(-3); %Risidual Tolerance
maxi=400; %Maximum Iteration
count=1; rele=re+1; res=rt+1; %Counter , reletive error, and residual
bad=0; %Boolean to pass to the plotter if it diverges

%%%%%%%%A bunch of code that I don't really think matters for this is here%%%%%%%%%

if rele >= 100 %Breaks loop if the values are diverging
disp('The relaxation is bad, try again');
count = 400;
break
end

function plotter(x1,x2,x3)
k=1;
for(w=0.01:0.002:0.6)
count=jacobi(x1,x2,x3,w);
curveJ(k,2)=count; %number of iterations required
curveJ(k,1)=w; %relaxation factor
k=k+1;
break
end

end
• Feb 27th 2010, 10:52 PM
elbarto
In the plotter function try:

Code:

`[bad, count]= jacobi(x1,x2,x3,w);`
`count=jacobi(x1,x2,x3,w);`