I nnet to plot two proportional function ??

I plot this function : function gamma=myfun(x) if x<=90 gamma=x ; else gamma=90; end end
now I want to plot another function 'exi' proportional to the first function cad if gamma <= 60 exi = 0 else exi = 1
please someone who can help me
thanks

 채택된 답변

Star Strider
Star Strider 2015년 5월 8일

0 개 추천

This works:
myfun = @(x) [x.*(x<=90) + 90*(x>90)];
cad = @(gamma) gamma>60;
x = linspace(0, 100);
gamma = myfun(x);
exi = cad(gamma);
figure(1)
plot(x, gamma, x, exi)
grid
legend('gamma', 'exi', 'Location','NW')

댓글 수: 3

khaled bkd
khaled bkd 2015년 5월 8일
Thank you so much for your help.
khaled bkd
khaled bkd 2015년 5월 8일
please if i need plot another function Vu=exi*sin(gamma)+2 ??
My pleasure!
In that instance, you can simply vectorise the equation you posted:
Vu = exi.*sin(gamma)+2;
^ INSERTED .TO VECTORISE THE EQUATION
or to create it as an anonymous function:
Vu = @(exi,gamma) exi.*sin(gamma)+2;
and then evaluated it as another variable, as I did in the code I posted.
Be certain that ‘exi’ and ‘gamma’ are the same size, or the equation assignment or function will throw an error.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2015년 5월 8일

댓글:

2015년 5월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by