Filter löschen
Filter löschen

Plot function shows an incomplete output

3 Ansichten (letzte 30 Tage)
Sagar D Patel
Sagar D Patel am 29 Jun. 2020
Kommentiert: Sagar D Patel am 29 Jun. 2020
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.

Akzeptierte Antwort

RAVIKIRAN YALAMARTHI
RAVIKIRAN YALAMARTHI am 29 Jun. 2020
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

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Identification finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by