# 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 ビュー (過去 30 日間)
VIKASH KUMAR 2020 年 7 月 31 日
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)

#### 2 件のコメント

VIKASH KUMAR 2020 年 7 月 31 日
function out=picker(condition, in1, in2)
if(condition==0)
out=in2;
else
out=in1;
end
this works

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

### 回答 (1 件)

Nitin Kapgate 2020 年 8 月 5 日
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

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

### Community Treasure Hunt

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

Start Hunting!

Translated by