How can i write this function in matlab?

조회 수: 15 (최근 30일)
Amna Althafeeri
Amna Althafeeri 2020년 2월 15일
답변: Walter Roberson 2020년 2월 15일
I want to plot this function
x(t) = 4(t+1)[u(t+1)-u(t)] + (4-2t)[u(t)-u(t-2)]
y= inline('4*g(t+1).*(u(t+1>=0)-u(t>=0)','t' )
I want to write x(t) in matlab , was my solution y for part of the equation correct or not?
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 2월 15일
inline is recommended against, and has been for close to 20 years. You should use anonymous functions instead.

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

답변 (1개)

Walter Roberson
Walter Roberson 2020년 2월 15일
No, u(t) represents the unit step function. You should use heaviside(t) but watch out for the value at heaviside(0)
You can also replace u(t) with double(t>=0)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by