필터 지우기
필터 지우기

Keep getting error about invalid parameter name.

조회 수: 50 (최근 30일)
Türker Atakan
Türker Atakan 2023년 10월 18일
편집: Walter Roberson 2023년 10월 18일
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)

채택된 답변

Shubham
Shubham 2023년 10월 18일
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.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2023년 10월 18일
T = table(a, a_t, p, d, 'variablenames', v_n);

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by