How to match table values to variables?
Show older comments
I am trying to write a function is which I solve for the work to but a satellite in orbit. The desired orbit is an input, so I have the variable named 'al' for altitude. Using this variable, I would import a table that lists three orbits and based off the input value, it would tell which orbit the satellite would be in. I am trying to solve this without hardcoding for the values (e.g. if 160<al<2000 - disp('orbit is low earth'), because then the imporation of the table would be useless.
Here's the code I have so far:
function thrust(ms,al) % setting up how the function will called with its parameters
% everything is in SI units
if al < 160 % The lowest satellit orbit is roughly 160km above Earth
disp('Altitude is too low, please choose a higher orbit.')
elseif al > 405000 % The farthest a satellite can orbit earth is 405000km above Earth
disp('Altitude is too high, please choose a lower orbit.')
else
%-------------------------------------------------------------------------
%This is the section where the code to solve for thrust, work, etc. is, so
%it is not relevant to the question.
%-------------------------------------------------------------------------
T = readtable('sat_table.xlsx') % create table T from sat_table.xlsx (visible)
T.Altitude; % drawing out altitude value column
% figure out a way to compare al to values in column
%-------------------------------------------------------------------------
end
end
The table in question:
Satellite Orbit Altitude
___________________________ ________________ ________
{'GOES, TV, Telephone' } {'High Earth' } 35780
{'Satellites like GPS' } {'Medium Earth'} 2000
{'Most General Satellites'} {'Low Earth' } 160
Accepted Answer
More Answers (0)
Categories
Find more on Reference Applications 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!