Plot function shows an incomplete output

8 次查看(过去 30 天)
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
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 中查找有关 Graphics Object Identification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by