The part of this I can\'t complete is converting the input string of the tempera
ID: 3796693 • Letter: T
Question
The part of this I can't complete is converting the input string of the temperature to a numeric value that can be used by the tF method. This is the work I have so far.
function [tF] = convertC(tC)
calctC = input('Enter Temperature ', 's');
convert = datenum(calctC,'s');
age = datestr(now-convert ,'s');
tC = age(end, end);
switch nargin
case 0
error('No initial temperature defined')
end
tF = ((9/5*tC)) + 32;
fprintf('%2.2f degrees F/n');
end
Write a function to convert C to Fin degrees. Test the function for 0C, 100C. Include an error message into function if a temperature is not inputted.Explanation / Answer
%function to convert celcius to degrees function [tF] = convertC(tC) if isempty(tC) %check for empty temperature error('No initial temperature defined') end tF = ((9/5*tC)) + 32; end calctC = input('Enter Temperature') %enter temperature in celcius y = convertC(calctC ) %call convert function sprintf('%2.2f degrees F/n',y) %print the converted farenhiet value
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.