input variable stored in matrice
Mostrar comentarios más antiguos
Hi there I wrote a program that could calculate the distance an object falls due to gravity. I prompted the user to enter a g amount and the program would calculate the the distance. Now i would like to store the specific g of the different planets in a matrice. The user would enter the name of the planet and matlab will then from there calculate the distance fallen. could anybody assist me or guide me to the right path. Much appreciated.
Respuesta aceptada
Más respuestas (2)
Michael Haderlein
el 5 de Ag. de 2014
e.g.
planets={'Earth','Moon','Mars'};
g=[9.81 1.62 3.71];
user_planet=inputdlg('Planet name: ');
planet_ID=strmatch(user_planet,planets);
if isempty(planet_ID)
msgbox('Planet not found');
else
user_g=g(planet_ID);
%further calculations
end
1 comentario
oselu
el 5 de Ag. de 2014
oselu
el 5 de Ag. de 2014
0 votos
Categorías
Más información sobre Earth and Planetary Science en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!