Scaling axes on plot

2 次查看(过去 30 天)
Rick
Rick 2014-9-17
评论: Rick 2014-9-17
Hello,
I am trying to make plots that are the same as the two plots at the bottom of this page http://www.umich.edu/~elements/5e/02chap/learn-cdp2_solution.html
For the very first plot (black), it has it basically at zero on my plot, but on the website the straight horizontal line is elevated
And I am having a problem with the second graph (green) at the bottom of the page because I don't have that straight line before the exponential decay.
For the third graph (blue), the scaling is not good which is why the line shoots straight up, instead of what the one on the website looks like
X = linspace(0,1,1000);
rA = (-10^-8)/3.*(X <= 0.5) + (-10^-8)./(3+10*(X-0.5)).*(X > 0.5);
f2 = @(x) 1./((-10^-8)./(3+10.*(x-0.5)));
figure
plot(X,-1./rA)
for i = 1:numel(X)
if X(i) <= 0.5
V_PFR(i) = (-1000/(10^-8/3)*-0.5);
else
V_PFR(i) = (-1000/(10^-8/3)*-0.5) + -1000*integral(f2,0.5,X(i));
end
end
figure
plot(V_PFR,-rA)
xlim([0 4.5e11])
xlabel('V_{PFR}')
ylabel('r_{A}')
title('r_{A} vs V_{PFR}')
figure
xlim([0 4.5e11])
plot(V_PFR,X)
xlabel('V_{PFR}')
ylabel('X')
title('Conversion vs. V_{PFR}')

采纳的回答

Adam
Adam 2014-9-17
编辑:Adam 2014-9-17
The first graph you can simply set:
ylim( [0 8e8] );
For the second graph you can just change the first value of V_PFR to 0 since it has a load of repeated values anyway:
V_PFR(1) = 0;
and plot as before.
The final graph suggests that the first 500 values of your V_PFR array should not be constant though. That appears to be more related to the maths than graph scaling. Solving that problem would also mean the second graph should be correct too without the need for the fudge described above.
Your
if X(i) <= 0.5
V_PFR(i) = (-1000/(10^-8/3)*-0.5);
seems to directly contradict what the 3rd graph on that page suggests, giving a constant value for x < 0.5 rather than the decreasing curve shown. That is not something I can help with though as I'm not at all familiar with the equations and can't afford that amount of time to look at them more deeply.
  1 个评论
Rick
Rick 2014-9-17
I see what was wrong, it was supposed to be
V_PFR(i) = (-1000/(10^-8/3)*-X(i));
However, the first graph didn't change when I put in the y-limits

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by