MATLAB Answers

How to Have an ANSWER that would depend upon the LETTER of your INPUT? Plz help me. thank you

1 view (last 30 days)
Kaye Freyssinet  Abanggan
Kaye Freyssinet Abanggan on 15 Sep 2016
Edited: Renato Agurto on 15 Sep 2016
This is for Celsius to Fahrenheit and vise versa. how to have a Fahrenheit answer if I input Example: 32 C? This is my code and i dont have any idea how. =( thanks for the help in advance
A=input('input:'); if A=input('##F') F=1.8*C+32 elseif A=input('##C') C=(F-32)*5/9 end

  3 Comments

Stephen Cobeldick
Stephen Cobeldick on 15 Sep 2016
The conversion between Celsius and Fahrenheit is very simple. Have you made any attempt to do your own homework ?
Kaye Freyssinet  Abanggan
Kaye Freyssinet Abanggan on 15 Sep 2016
This is for Celsius to Fahrenheit and vise versa. how to have an answer that would depend on the letter ?
A=input('input:'); if A=input('##F') F=1.8*C+32 elseif A=input('##C') C=(F-32)*5/9 end
Steven Lord
Steven Lord on 15 Sep 2016
A couple of functions or keywords that may be of use to you are isequal, switch and case, lower, and/or upper.

Sign in to comment.

Answers (1)

Renato Agurto
Renato Agurto on 15 Sep 2016
Edited: Renato Agurto on 15 Sep 2016
Here is a little help
function output = your_function(str)
unit = str(end); %should be 'F' or 'C'
val = str2double(str(1:end-1)); %should be a number
%Your computation comes here:
% output = ....
end

  0 Comments

Sign in to comment.

Sign in to answer this question.