MATLAB: How to insert the input of a string into an input asking for a number

inputstring

My example is naming a planet then asking for the mass of that specific planet in the next line. How do I call the name of the planet as a string into the second line?

Best Answer

I prefer using the inputdlg funciton.
This works:
p_namec = inputdlg('What is the name of the planet? ');
p_massc = inputdlg(sprintf('What is the mass of %s? ', p_namec{:}));
p_mass = str2num(p_massc{:}); % Numeric Value