Plotting a multivariable function
조회 수: 3(최근 30일)
표시 이전 댓글
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
채택된 답변
KALYAN ACHARJYA
2022년 10월 30일
편집: KALYAN ACHARJYA
2022년 10월 30일
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
KALYAN ACHARJYA
2022년 10월 30일
편집: KALYAN ACHARJYA
2022년 10월 30일
#Your Comment: Edited: TTo run the code here itself (Tap Green Tringular Button-Online) or try it on Matlab Platform (System-Offline)
추가 답변(0개)
참고 항목
범주
Find more on Migrate GUIDE Apps 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!