planet = input('What planet do you want to visit? ','s');weight = input('Great! How much do you weigh on Earth? ');if planet strcmp ('Mercury') new_weight = .37 * weightelseif planet == 'Venus' new_weight = .90 * weightelseif planet == 'Earth' fprintf('You''ve already been to Earth!')elseif planet == 'Moon' new_weight = .17 * weightelseif planet == 'Mars' new_weight = .38 * weightelseif planet == 'Jupiter' fprintf('This is a gas giant, you might not be able to stand on it!') new_weight = 2.65 * weightelseif planet == 'Saturn' fprintf('This is a gas giant, you might not be able to stand on it!') new_weight = 1.13 * weightelseif planet == 'Uranus' fprintf('This is a gas giant, you might not be able to stand on it!') new_weight = 1.09 * weightelse fprintf('This is a gas giant, you might not be able to stand on it!') new_weight = 1.43 * weightend
MATLAB: I have the user input a string, then I try and use the string in an if statment, but matlab keeps telling me the matrix dimensions don’t agree, and I don’t have a matrix
if-statementsinputstrings
Best Answer