Want to plot iteration results

3 views (last 30 days)
Amjad
Amjad on 14 Mar 2011
Dear All, Good day! I have written the following code to solve for iterative equations called from another file. Now I want to plot the results of the iteration along the length, z with incriments of "delz" for each of 7 parameters. Any help shall be appreciated. The code is as follows.
clear all clc
global u Pt0 counter delz delP u01 u02 u03 u04 u05 u06 u013 kg hi
x0 = [0.197;0.015;0.085;0.497;0.200;0.006;0.197;0.015;0.085;0.497;0.200;0.006;880;880]; %initial guess for fsolve u01=0.2278; u02=0.00157; u03=0.00768; u04=0.7279; u05=0.02796; u06=0.00729; u013=893; %***Inlet condition***** % u01=0.900; u02=0.0269; u03=0.008; u04=0.001e-03; u05=0.03; u06=0.0351; u013=893; %***Inlet condition*****
Pt0=24; % bar delP=1.4; % bar L=14.35; % m delz=L/15; % m counter=2;
options=optimset('LargeScale','off','TolX',1e-8,'MaxIter',1e8,'MaxFunEvals',2e20); f='ReportS';
w(1,1)=u01; w(1,2)=u02; w(1,3)=u03; w(1,4)=u04; w(1,5)=u05; w(1,6)=u06; w(1,13)=u013; w(1,14)=NaN;
% ------ Solving Steady-State Model Equations for 15 Nodes in the Reactor ------
while counter<17
[u,fval] = fsolve(@MyfuncMSR1,x0,options);
w(counter,:)=u';
x0=u;
u01=w(counter,1);
u02=w(counter,2);
u03=w(counter,3);
u04=w(counter,4);
u05=w(counter,5);
u06=w(counter,6);
u013=w(counter,13);
Pt0=Pt0-(delP/L)*delz;
counter=counter+1;
end
save(f,'w')

Answers (2)

Sean de Wolski
Sean de Wolski on 14 Mar 2011
doc plot
doc hold
perhaps? What is your actual question?
  1 Comment
Amjad
Amjad on 14 Mar 2011
Thx for replying Sean. My question is simple... how to get plots of iteration. Wat i get is a single value after solving teh equations. Now, if I want to plot the track of all iterations, how should I procede? Hope I get it clear this time. Thnx

Sign in to comment.


Sean de Wolski
Sean de Wolski on 14 Mar 2011
figure; hold on;
while ...
calculate stuff
plot(stuff)
drawnow;
pause('if you want');
end

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!