フィルターのクリア

Use user input in a function

1 回表示 (過去 30 日間)
Chesus
Chesus 2023 年 9 月 6 日
回答済み: kei hin 2023 年 9 月 6 日
I want to use a user input variable in a function
like:
n=input('n')
k=3
f1=func(k)
function f1=func(x);
f1=n*x;
end
But when I write that code it gives me this message:
Unrecognized function or variable 'n'.
Error in untitled>func (line 5)
f=n*x;
How can I do this?

採用された回答

kei hin
kei hin 2023 年 9 月 6 日
k=3
f1=func(k)
function f1=func(x);
n=input('n')
f1=n*x;
end
or
n=input('n')
k=3
f1=func(n,k)
function f1=func(n,x);
f1=n*x;
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by