MATLAB: I am working on homework. I am to prompt user for temperature in Celsius and then ask them to choose if they want it converted to F or C. I have this so far. It promted user for temp in C and converted to F before I started to add a while loop,

ask userMATLAB

I am working on homework. I am to prompt user for temperature in Celsius and then ask them to choose if they want it converted to Farenheit or Kelvin. I have this so far. It promted user for temp in C and converted to F before I started to add a while loop, which is how I was thinking to get the user to choose the input, I also made the display a comment while I play with it. My question really is how to write ask user to choose Farenheit or Kelvin for the answer. I think maybe ifelse would work better. Also I did try to get with my professor about this he is not available before this is due. Just need some help.
Thanks yall
%This will take temp in Celsius and return it in either Farenhiet or Kelvin
C = input('Please enter a temperature value in Celsius.');
K = C+273.15
F = (9/5)*C+32
while 1
end
%fprintf('The temperature in Farenheit is: %d.\n', F)

Best Answer

You could use the question dialogue box, see the example below. You could first prompt for the temperature number and then ask if they want Farenhiet or Kelvin with the questdlg function similar to the example below. Instead of the "desert =" lines you would substitue in your code for the right conversion formula. You will only need 2 cases for your assignment. Hope this helps get your started in the right direction.
answer = questdlg('Would you like a dessert?', ...
'Dessert Menu', ...
'Ice cream','Cake','No thank you','No thank you');
% Handle response
switch answer
case 'Ice cream'
disp([answer ' coming right up.'])
dessert = 1;
case 'Cake'
disp([answer ' coming right up.'])
dessert = 2;
case 'No thank you'
disp('I''ll bring you your check.')
dessert = 0;
end