enable/disable parameter in embedded matlab function

조회 수: 2 (최근 30일)
st
st 2013년 3월 16일
hello, i've got an embedded matlab function with several parameters(variables). I try to enable/disable parameter 1 and 2 in dependency on parameter 3. Means, if the value of parameter 3 is "1", parameter 1 is enabled and parameter 2 is disabled. If the value of parameter 3 is "2", both parameters are enabled. Is there a possibility for this?
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 16일
Can you explain what you mean by enable and disable?
st
st 2013년 3월 16일
yes, for example i have the parameters a,b,c,d and a function y=a+b+c. If parameter "d" has the value 1 --> y=a. if parameter "d" has the valua 2 --> y=a+b. if parameter "d" has the value 3 --> y=a+b+c.
hope this is understandable. Another idee was to enable/disable the inputports for a,b and c

댓글을 달려면 로그인하십시오.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 16일
편집: Azzi Abdelmalek 2013년 3월 16일
function y=fcn(a,b,c,d)
if d==1
y=a
elseif d==2
y=a+b
elseif d==3
y=a+b+c
end
%or
function y=fcn(a,b,c,d)
v=[a b c];
y=sum(v(1:d))
  댓글 수: 2
st
st 2013년 3월 16일
it can be so simple. thanks a lot!
Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 16일
If the answer helped, then mark it as accepted

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by