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
이전 댓글 표시
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:
- out=picker(true,1,2)
- out=picker(false,1,2)
댓글 수: 4
VIKASH KUMAR
2020년 7월 31일
Aditya Vadduri
2020년 11월 1일
function out=picker(condition, in1, in2)
if(condition==0)
out=in2;
else
out=in1;
end
this works
Abdulsalam ALMABROUK
2021년 5월 31일
function out = picker(condition,in1,in2)
if condition == 1;
out = in1;
else
out = in2;
end
Ibad Ur Rahman
2022년 4월 4일
function out=picker(condition,in1,in2)
if condition==1
out=in1;
else
out=in2;
end
답변 (3개)
Chandan Kumar
2021년 3월 1일
function out = picker(condition,in1,in2)
if (condition==1)
out=in1
else
out=in2
end
Nitin Kapgate
2020년 8월 5일
0 개 추천
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
VIGNESH B S
2021년 10월 13일
function ret = picker(condition,in1,in2)
if condition == 1
ret = in1;
else
ret = in2;
end
end
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!