Need some help with my function, why do I keep getting an error?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
T.Y. Hilton
am 2 Mär. 2018
Kommentiert: Birdman
am 2 Mär. 2018
I am supposed to write a function that accepts temperature in degrees Fahrenheit(°F) and returns the corresponding value in degrees Celsius (°C). Here is my code:
function [Celsius] = TemperatureConversion(Fahrenheit)
Celsius = (5/9)*(Fahrenheit-32);
When I run this code, I get this:
>> TemperatureConversion
Not enough input arguments.
Error in TemperatureConversion (line 12)
Celsius = (5/9)*(Fahrenheit-32);
Why am I getting this error?
1 Kommentar
Stephen23
am 2 Mär. 2018
Error in TemperatureConversion (line 12)
Why does the error message say line 12? You showed us two lines of code: this tells us that the code you have shown us is not the complete code in the file that you are trying to run, so we have no idea what you are actually trying to do.
Akzeptierte Antwort
Birdman
am 2 Mär. 2018
Bearbeitet: Birdman
am 2 Mär. 2018
You should save the function in a m file and then call it from command line as:
fah=77;
degree=TemperatureConversion(fah)
You need to read this documentation carefully.
8 Kommentare
Birdman
am 2 Mär. 2018
You are welcome. These are very basic concepts, learn them well to proceed well.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!