Plotting a multivariable function
2 views (last 30 days)
Show older comments
Hi, I have a multivariable function as you can see down below. The function works perfect but I have a problem. I need to plot v_cal - v_true when a_ft is equal to 28000. However, when I tried to run the function, MATLAB asks me for v_cal and a_ft values. When I input these values, it plots the v_cal-v_true graph as a constant function. How can I fix this? Thanks in advance.
function v_true=CaltoTrue(a_ft,v_cal)
a=a_ft*0.3048;
b=-0.0065;
R=287.05287;
gr_0=9.80665;
p0=101325;
T0=288.15;
pr=p0*((T0+b*a)/T0)^(-gr_0/(b*R));
T=T0+b*a;
ad=pr/(R*T);
k=1.4;
nu=(k-1)/k;
ad_0=1.225;
v_true=(((((1+(nu*ad_0*(v_cal)^2)/(2*p0))^(1/nu)-1)*p0/pr+1)^nu-1)*(2*pr)/(nu*ad))^(1/2);
if a_ft==28000
v_cal=0:500;
fplot(v_true)
xlabel('V_Cal')
ylabel('V_True')
end
end
0 Comments
Accepted Answer
KALYAN ACHARJYA
on 30 Oct 2022
Edited: KALYAN ACHARJYA
on 30 Oct 2022
a_ft=28000;
v_cal=0:500;
CaltoTrue(a_ft,v_cal)
function v_true=CaltoTrue(a_ft,v_cal)
a=a_ft*0.3048;
b=-0.0065;
R=287.05287;
gr_0=9.80665;
p0=101325;
T0=288.15;
pr=p0*((T0+b*a)/T0)^(-gr_0/(b*R));
T=T0+b*a;
ad=pr/(R*T);
k=1.4;
nu=(k-1)/k;
ad_0=1.225;
temp=nu*ad_0.*(v_cal).^2;
temp2=(1+temp/(2*p0)).^(1/nu)-1;
v_true=(((temp2.*p0/pr+1).^(nu)-1).*(2*pr)/(nu*ad)).^(1/2);
plot(v_true)
grid on;
xlabel('V_Cal')
ylabel('V_True')
end
#Not costant, there is a slight variation, please check the equation, it is more about digging those equations rather than matlab code.
2 Comments
KALYAN ACHARJYA
on 30 Oct 2022
Edited: KALYAN ACHARJYA
on 30 Oct 2022
#Your Comment: Edited: TTo run the code here itself (Tap Green Tringular Button-Online) or try it on Matlab Platform (System-Offline)
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!