How to use input command?

4 次查看(过去 30 天)
Shawn Simon
Shawn Simon 2015-10-23
评论: Shawn Simon 2015-10-23
The purpose of these two lines is for the user to input the name the "planet", then the next question asks the mass of the planet. In the second line, I am trying to call the variable 'name' so the question in line 2 incorporates the name of the planet. However, I get an error on the second line saying "Too many input arguments". Also, I am new to MATLAB. Please help
name = input('What is the name of the exoplanet? ', 's');
massplanet = input('What is the estimated mass of %s (kg)? ', 's', name);

采纳的回答

Adam
Adam 2015-10-23
编辑:Adam 2015-10-23
massplanet = input( sprintf('What is the estimated mass of %s (kg)? ', name), 's');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Earth and Planetary Science 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by