Not enough input arguments.

function cel=myf2c(far)
cel= (far - 32) * 5 / 9;
end

2 件のコメント

Simay Kayra
Simay Kayra 2024 年 5 月 1 日
It says Error in myf2c (line 2)
cel= (far - 32) * 5 / 9;
Sam Chak
Sam Chak 2024 年 5 月 1 日
No error when I run it.
TempF = 100;
TempC = myf2c(TempF)
TempC = 37.7778
%% Fahrenheit to Celsius Temperature Unit Converter
function cel = myf2c(far)
cel = (far - 32) * 5 / 9;
end

サインインしてコメントする。

回答 (1 件)

Sam Chak
Sam Chak 2024 年 5 月 1 日

0 投票

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()
Not enough input arguments.

Error in solution>myf2c (line 2)
cel = (far - 32) * 5 / 9;

5 件のコメント

Simay Kayra
Simay Kayra 2024 年 5 月 1 日
what can i do about error message?
Stephen23
Stephen23 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
ans = 37.7778
myf2c() % what you are doing
Not enough input arguments.

Error in solution>myf2c (line 5)
cel = (far-32) * 5 / 9;
function cel = myf2c(far)
cel = (far-32) * 5 / 9;
end
Simay Kayra
Simay Kayra 2024 年 5 月 1 日
when i hit the run button on script place it says Not enough input arguments. But if i ignore this error message and go to the workspace and call my function then type a input value. It gives me a what exactly i want. But i have still error message on my script place. What can i do?
Torsten
Torsten 2024 年 5 月 1 日
編集済み: Torsten 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
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 ExchangeStructures についてさらに検索

製品

質問済み:

2024 年 5 月 1 日

コメント済み:

2024 年 5 月 1 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by