a = input('What is the name of the exoplanet? ','s');
mass = input('What is the mass of %s (kg)? ', a)
radius = input('What is the estimated radius of %s (km)? ', a)
masssp = input('What is the mass of the specimen (kg) ')
newton = (mass * radius)/masssp
fprintf('On %s , it would weight approxomately %d Newtons ', s, newton)
答案 0 :(得分:0)
你的文字需要sprintf
a = input('What is the name of the exoplanet? ','s');
mass = str2num(input(sprintf('What is the mass of %s (kg)?', a),'s'));
radius = str2num(input(sprintf('What is the estimated radius of %s (km)?', a),'s')) ;
然后将您的字符串转换为数字,否则您无法使用它进行计算...