What is wrong with this easy script
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
in a new script,
Hello,
I am new in Matlab. I am practicing. I don´t know why, Matlab don´t accept this code:
function out=picker(condition,in1,in2)
if condition == 1
out=in1;
elseif condition == 0
out=in2;
end
What is wrong?
Thank you for you time
2 Commenti
David Hill
il 12 Lug 2020
There is nothing wrong with it. How are you calling it? There is one thing that would simplify and always provide an output.
function out=picker(condition,in1,in2)
if condition %no need for ==1
out=in1;
else %no need for elseif
out=in2;
end
end
% should call function
a = picker(1,1,5) % need three inputs to the function
Risposta accettata
Image Analyst
il 12 Lug 2020
You need to pass in something. You can't just click the green Run triangle without passing in anything for the arguments. For example, you could do this from the command line:
>>out = picker(true, 42, 73)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Digital Filter Analysis 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!