Borrar filtros
Borrar filtros

Keep getting error about invalid parameter name.

50 visualizaciones (últimos 30 días)
Türker Atakan
Türker Atakan el 18 de Oct. de 2023
Editada: Walter Roberson el 18 de Oct. de 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)

Respuesta aceptada

Shubham
Shubham el 18 de Oct. de 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.

Más respuestas (1)

Walter Roberson
Walter Roberson el 18 de Oct. de 2023
T = table(a, a_t, p, d, 'variablenames', v_n);

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by