Plot function shows an incomplete output

조회 수: 6 (최근 30일)
Sagar D Patel
Sagar D Patel 2020년 6월 29일
댓글: Sagar D Patel 2020년 6월 29일
Hello,
I have a simple function created titled Pcg:
function f = Pcg(Pe)
f = sqrt(Pe./4.0+1.273).*1.11;
I aim to call it in the code below to obtain an output of the dotted curve, d, shown in the attached image:
pe_plot = linspace(0,1000,10000);
plot(sort(pe_plot),Pcg(sort(pe_plot)));
xlim([0.01,1000])
ylim([0.1,30])
set(gca,'xscale','log')
set(gca,'yscale','log')
I am however obtaining a blank region in the plot for x-values between 0.01 and 0.1. This also got me thinking that I'm probably goofing up big time in using linspace for plotting. The curve shown in the attached image is just a prediction curve, where values on the y-axis are plotted as function of an array of values on the x-axis.

채택된 답변

RAVIKIRAN YALAMARTHI
RAVIKIRAN YALAMARTHI 2020년 6월 29일
Create a linspace array which matches the log sclae for x- axis values. (Since, you set the xlim as [0.01,1000])
pe_plot = linspace(0.010,1000,10000)
plot(sort(pe_plot),Pcg(sort(pe_plot)),'--')
to add '+' marking on dashep plot,
hold on
s = [0.01 0.1 1 5 10 50 100 500 1000]
plot(s,Pcg(s),'+r')
hold off
and remaining code is as it is to get the curve 'd' as shown in image
xlim([0.01,1000])
ylim([0.1,30])
set(gca,'xscale','log')
set(gca,'yscale','log')
function f = Pcg(Pe)
f = sqrt(Pe./4.0+1.273).*1.11;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by