# Q write a function called picker that takes three arguments called condition, in1 and in2 in this order. The argument condition is a logical. If it is true, the function assigns the value of in1 to the output argument out, otherwise, it assigns the v

64 visualizzazioni (ultimi 30 giorni)
VIKASH KUMAR il 31 Lug 2020
Commentato: Ibad Ur Rahman il 4 Apr 2022
Q write a function called picker that takes three arguments called condition, in1 and in2 in this order. The argument condition is a logical. If it is true, the function assigns the value of in1 to the output argument out, otherwise, it assigns the value of in2 to out.
Code to call function:
1. out=picker(true,1,2)
2. out=picker(false,1,2)
##### 4 CommentiMostra 2 commenti meno recentiNascondi 2 commenti meno recenti
Abdulsalam ALMABROUK il 31 Mag 2021
function out = picker(condition,in1,in2)
if condition == 1;
out = in1;
else
out = in2;
end
Ibad Ur Rahman il 4 Apr 2022
function out=picker(condition,in1,in2)
if condition==1
out=in1;
else
out=in2;
end

Accedi per commentare.

### Risposte (3)

Chandan Kumar il 1 Mar 2021
function out = picker(condition,in1,in2)
if (condition==1)
out=in1
else
out=in2
end
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Nitin Kapgate il 5 Ago 2020
Hi Vikash,
I understand that you need to write a function (“picker”) which takes three inputs and return one output based on the first argument, which is of logical type.
An answer to a similar question can be found here
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

VIGNESH B S il 13 Ott 2021
function ret = picker(condition,in1,in2)
if condition == 1
ret = in1;
else
ret = in2;
end
end
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Line Plots 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!

Translated by