Not enough input arguments.
显示 更早的评论
function cel=myf2c(far)
cel= (far - 32) * 5 / 9;
end
2 个评论
Simay Kayra
2024-5-1
No error when I run it.
TempF = 100;
TempC = myf2c(TempF)
%% Fahrenheit to Celsius Temperature Unit Converter
function cel = myf2c(far)
cel = (far - 32) * 5 / 9;
end
回答(1 个)
I managed to replicate the error message by leaving the argument empty. Therefore, you should provide a Fahrenheit value for it, as shown in my example above.
function cel = myf2c(far)
cel = (far - 32) * 5 / 9;
end
TempF = 100;
TempC = myf2c()
5 个评论
Simay Kayra
2024-5-1
"what can i do about error message?"
Very simple: call your function with an input value. Calling it without an input will throw an error:
myf2c(100) % no error
myf2c() % what you are doing
function cel = myf2c(far)
cel = (far-32) * 5 / 9;
end
Simay Kayra
2024-5-1
1. Save this as "myf2c.m" in your working directory:
function cel=myf2c(far)
cel= (far - 32) * 5 / 9;
end
2. Save this as "call.m" in your working directory:
TempF = 100;
TempC = myf2c(TempF)
3. Load "call.m" in the MATLAB editor.
4. Hit the "Run" button.
5. Invest 2 hours of your time and pass the Onramp introduction to MATLAB free of costs:
Steven Lord
2024-5-1
If you want to run this code with the Run button, click the small downward-pointing triangle below the word Run. Enter the code you want to run (with the input argument) where it says "type code to run" and press Enter. When I did that, typing the following as the code to run, it worked.
myf2c(100)
类别
在 帮助中心 和 File Exchange 中查找有关 Structures 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!