Why is my second plot only coming up when I run the program?

3 ビュー (過去 30 日間)
Yianni
Yianni 2014 年 11 月 8 日
コメント済み: Star Strider 2014 年 11 月 8 日
I have a function file and script file that both work well together, but out of the two plots I am trying to show when I run the program, only the second one shows up. Can anyone tell me why this is happening?
My function file:
function ff = fCW()
F = @(f,Re) 2*log10(Re*sqrt(f))-0.8-(1/sqrt(f));
Re = linspace(1e4,1e7,121);
ff = zeros(size(Re));
for k = 1:length(Re)
ff(k) = fzero( @(f) F(f,Re(k)), 0.05 );
end
end
My script file:
FCW = fCW();
Re1=linspace(1e+4,1e+7,121); NRe1=length(Re1);
fB = zeros(size(Re1)); fSJ = fB;
for i=1:NRe1
fSJ(i)=0.25/(log10(5.74/Re1(i)^0.9))^2;
fB(i)=0.3164/Re1(i)^0.25;
end
plot(Re1, FCW, Re1, fSJ, Re1, fB)
xlabel('Reynolds Number'); ylabel('Dimensionless Friction Factor');
title('Three Friction Factor Correlations for Smooth Pipes')
legend('Colebrook-White Correlation', 'Swamee-Jain Correlation',...
'Blasius Correlation')
plot(fB,FCW,fSJ,FCW)
xlabel('Dimensionless Friction Factor');
ylabel('Dimensionless Friction Factor');
legend('Ratio of Blasius to Colebrook-White Correlation',...
'Ratio of Swamee-Jain to Colebrook-White Correlation')

採用された回答

Star Strider
Star Strider 2014 年 11 月 8 日
MATLAB will plot in the same open axes object unless it to create a new one.
Do this:
figure(1)
plot(Re1, FCW, Re1, fSJ, Re1, fB)
... CODE ...
figure(2)
plot(fB,FCW,fSJ,FCW)
... CODE ...
and they should both be visible (although you will probably have to toggle between them or offset them from one another to see them both).
  2 件のコメント
Yianni
Yianni 2014 年 11 月 8 日
It works! Thank you again, you have been very helpful.
Star Strider
Star Strider 2014 年 11 月 8 日
My pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by