Surface Plot or Mesh Plot

I am quite naive to MATLAB, so i beg your apology for asking simple questions. Here is the code:
A=50;
tau=1;
P_f=0.02;
for i=1:100
v0(i)=i;
v(i)=v0(i).*5/18;
Kf=tan(atan((v(i).*tau)/sqrt((4*A^2)-((v(i)^2)*(tau^2))))-((pi*P_f)/2));
M=(2*A*Kf)/(v(i).*sqrt(1+Kf^2));
Phf(i)=(2/pi)*(atan((v(i).*tau)/sqrt((4*A^2)-(((v(i))^2)*tau^2)))-atan((v(i).*M)/sqrt((4*A^2)-(((v(i))^2)*M^2))));
end
plot (v0,Phf)
Now, how to make a Surface Plot or Mesh Plot of this ?

6 Kommentare

Azzi Abdelmalek
Azzi Abdelmalek am 13 Jul. 2014
Bearbeitet: Azzi Abdelmalek am 13 Jul. 2014
You need three variables. What are they?
Adnan
Adnan am 13 Jul. 2014
I just have two variables here ~ v0 and Phf. How to define this third matrix or vector
Star Strider
Star Strider am 13 Jul. 2014
Which other one do you want to plot: Kf, M, or something else?
Adnan
Adnan am 13 Jul. 2014
Can you just help me to adjust the scale of this plot (as per the above code). The plot comes around 0.02, but i can't figure out the exact values on the y axis with respect to the x axis. I need something where i can clearly see the rising or the declining points
When I calculated your data, the range (max(Phf)-min(Phf)) = 69.3889e-018. The variations in Phf are on the order of machine precision.
Do this calculation (dPhf/dv0) and plot to illustrate that:
dPhfdv0 = diff([Phf])./diff([v0]);
plot(dPhfdv0)
Adnan
Adnan am 14 Jul. 2014
Thanks Star Strider. I m calculating probability and it can't be negative. Is there any method to avoid negative probabilities in this plot, plot(dPhfdv0)

Antworten (1)

Star Strider
Star Strider am 14 Jul. 2014

0 Stimmen

Probabilities are by definition always positive.
I used dPhfdV0 to illustrate the fact that your Phf array has very little variation. If you want to calculate the statistics, I would calculate those on Phf itself. Calculating the mean and standard deviation are easy enough:
Phfmn = mean(Phf)
Phfsd = std(Phf)
If you want the values that will define the range that Phf will be found within with 95% probability, you can calculate them as:
PhfRng95 = [Phfmn-1.96*Phfsd Phfmn+1.96*Phfsd]
You have to use format long e to see the details of PhfRng95. The value of 1.96 is the inverse normal distribution for the probabilities of 0.025 and 0.975, encompassing a total probability of 0.95.

Diese Frage ist geschlossen.

Gefragt:

am 13 Jul. 2014

Geschlossen:

am 20 Aug. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by