# Plotting a multivariable function

4 visualizzazioni (ultimi 30 giorni)
Sazcl il 30 Ott 2022
Modificato: KALYAN ACHARJYA il 30 Ott 2022
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;
k=1.4;
nu=(k-1)/k;
if a_ft==28000
v_cal=0:500;
fplot(v_true)
xlabel('V_Cal')
ylabel('V_True')
end
end
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

KALYAN ACHARJYA il 30 Ott 2022
Modificato: KALYAN ACHARJYA il 30 Ott 2022
a_ft=28000;
v_cal=0:500;
CaltoTrue(a_ft,v_cal)
ans = 1×501
0 1.5762 3.1524 4.7285 6.3046 7.8806 9.4565 11.0323 12.6079 14.1833 15.7586 17.3336 18.9084 20.4830 22.0573 23.6312 25.2049 26.7782 28.3512 29.9238 31.4960 33.0678 34.6391 36.2100 37.7804 39.3503 40.9197 42.4885 44.0568 45.6245
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;
k=1.4;
nu=(k-1)/k;
temp2=(1+temp/(2*p0)).^(1/nu)-1;
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 CommentiMostra NessunoNascondi Nessuno
Sazcl il 30 Ott 2022
a_ft=28000;
v_cal=0:500;
CaltoTrue(a_ft,v_cal)
ans = 1×501
0 1.5762 3.1524 4.7285 6.3046 7.8806 9.4565 11.0323 12.6079 14.1833 15.7586 17.3336 18.9084 20.4830 22.0573 23.6312 25.2049 26.7782 28.3512 29.9238 31.4960 33.0678 34.6391 36.2100 37.7804 39.3503 40.9197 42.4885 44.0568 45.6245
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;
k=1.4;
nu=(k-1)/k;
temp2=(1+temp/(2*p0)).^(1/nu)-1;
plot(v_true)
grid on;
xlabel('V_Cal')
ylabel('V_True')
end
Thanks a lot, but I don't understand where exactly you wrote the first three lines of code. When I place it above the function, I get this error: Local function name must be different from the script name.
KALYAN ACHARJYA il 30 Ott 2022
Modificato: KALYAN ACHARJYA il 30 Ott 2022
#Your Comment: Edited: TTo run the code here itself (Tap Green Tringular Button-Online) or try it on Matlab Platform (System-Offline)

Accedi per commentare.

### Categorie

Scopri di più su Annotations in Help Center e File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by