Input multiple items and solve a function for those values?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
℉ = 9/5*℃ + 32
For this problem, write a function m-file that does the following:
1. Accepts two inputs, a low temperature and a high temperature both in Celsius.
2. Defines an anonymous function in the function workspace that converts temperatures from Celsius to
Fahrenheit.
3. Uses the anonymous function to convert each input temperature to Fahrenheit.
4. Calculates the difference between the two temperatures in Fahrenheit.
5. Outputs three results: the low temperature in Fahrenheit, the high temperature in Fahrenheit, and the difference between the temperatures in Fahrenheit.
... So I've got it to where I can convert the two temperature inputs in F to C. But I cannot for the life of me figure out how to calculate the difference between the two and then end up with three outputs. I'm new to Matlab so its all pretty confusing right now and I would really love some advice as to how to approach this problem! Thanks
Here is what I have so far:
prompt = 'Convert temperature to Fahrenheit? ';
result = input(prompt);
str = input(prompt,'s');
F = @(C) ((9./5).*C)+32;
F(result);
disp(X)
0 commentaires
Réponses (1)
David Sanchez
le 16 Oct 2013
function [F1,F2,Fd] = my_faran(C1,C2)
F = @(C) ((9./5).*C)+32;
F1 = F(C1);
F2 = F(C2);
Fd = F1-F2;
Call the function like this (change the input values as you please):
[F1,F2,Fd] = my_faran(10,30)
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!