Use user input in a function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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'.
f=n*x;
How can I do this?
0 Commenti
Risposta accettata
kei hin
il 6 Set 2023
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Test Model Components in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!