Filter löschen
Filter löschen

Keep getting error about invalid parameter name.

50 Ansichten (letzte 30 Tage)
Türker Atakan
Türker Atakan am 18 Okt. 2023
Bearbeitet: Walter Roberson am 18 Okt. 2023
I'm attempting to create a table in Matlab that shows temperature, pressure and air density changes over altitute. Got stuck on the table side of things.
clear; clc;
i_a = input ('Enter Initial Altitude: ');
e_a = input ('Enter End Altitude: ');
i = input ('Enter Increment: ');
o_t = input ('Enter Offset Temperature: ');
while i_a > 33000 || e_a > 33000
fprintf('You have left the Troposphere. Please input values smaller than or equal to 33,000 ft. \n');
i_a = input ('Enter Initial Altitude: ');
e_a = input ('Enter End Altitude: ');
i = input ('Enter Increment: ');
o_t = input ('Enter Offset Temperature: ');
end
while i_a < 0 || e_a < 0
fprintf('You have gone under sea level. Are you Dutch? Please input values bigger than or equal to 0 ft. \n');
i_a = input ('Enter Initial Altitude: ');
e_a = input ('Enter End Altitude: ');
i = input ('Enter Increment: ');
o_t = input ('Enter Offset Temperature: ');
end
a = [];
a_t = [];
p = [];
d = [];
c_a = i_a;
while c_a <= e_a
a = [a; c_a];
c_a = c_a + i;
m_a = a * 0.3048;
a_t = 288.15 + o_t - 0.00649 * m_a;
p = 101325 * ((1 - 0.00649 * m_a / 288.15).^(9.806/(287.052874*0.00649)));
d = p / (287.052874 * a_t);
end
v_n = {'Altitute in ft', 'Air Temperature in Kelvin', 'Pressure in Pascal', 'Air Density in kg/m^3'};
T = table(a, a_t, p, d, 'v_n');
disp(T);
I keep getting this error but I'm not sure what I did wrong: Error using table Invalid parameter name: v_n.
It can make a table using v_n but can not fill the values on the table.
It also seems to put d as a 67x67 table while it makes all others 67x1 (edited)

Akzeptierte Antwort

Shubham
Shubham am 18 Okt. 2023
I understand you are getting an error while running the code.
The issue in your code lies in the way you are specifying the variable names for the table. Instead of passing the variable "v_n" as a parameter to the table function, you should pass it as a separate argument using the 'VariableNames' parameter.
Here's the corrected code:
% Your existing code
v_n = {'Altitute in ft', 'Air Temperature in Kelvin', 'Pressure in Pascal', 'Air Density in kg/m^3'};
T = table(a, a_t, p, d, 'VariableNames', v_n);
disp(T);
Hope this will fix the issue.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 18 Okt. 2023
T = table(a, a_t, p, d, 'variablenames', v_n);

Kategorien

Mehr zu Dates and Time 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