Put multiple loglog plots on one figure
이전 댓글 표시
Hello...I am trying to put 3 loglog plots on the same figure but this is not working. Any recommendations or small things I'm missing?
Thanks! :)
clear
clc
close all
format short
Re = 10^4:1000:10^8;
%Bruus
B = @(x) .25*(log((x/3.7)+(5.74./(Re).^.9)));
%Haaland
H = @(x) (1./(-1.8*log((x/3.7)^1.11+(6.9./Re)))).^2;
%Figure 1
eD1 = 0;
B1 = B(eD1);
H1 = H(eD1);
figure;
loglog(Re,B1,'r')
hold on
loglog(Re,H1,'--')
title('f vs. Re e/D = 0');
xlabel('Re');
ylabel('f');
legend('Bruus','Haaland');
grid on
답변 (1개)
madhan ravi
2018년 10월 31일
0 개 추천
Isn’t this normal? because the domain of the log function starts from 0+ to wards positive infinity that’s why it’s ignoring negative arguments.
댓글 수: 5
madhan ravi
2018년 10월 31일
There’s nothing wrong with the code because you have used hold on option which is supposed to hold multiple plots in one figure but as i said there’s some malfunctioning in mathematics.
madhan ravi
2018년 10월 31일
See in your B , log(0/3.7) is exactly the same as log(0) log doesn’t contain zero as it’s domain since it starts from 0+ as mentioned before :)
madhan ravi
2018년 10월 31일
편집: madhan ravi
2018년 10월 31일
See http://www.astro.umd.edu/~cychen/MATLAB/Logarithmic_Scaling_Info.html , read the last paragraph in the link.
Josh Glenn
2018년 10월 31일
madhan ravi
2018년 10월 31일
It should plot all the graphs if you fix the mathematical error.
카테고리
도움말 센터 및 File Exchange에서 General Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!