How can i write this function in matlab?

18 Ansichten (letzte 30 Tage)
Amna Althafeeri
Amna Althafeeri am 15 Feb. 2020
Beantwortet: Walter Roberson am 15 Feb. 2020
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 Kommentar
Walter Roberson
Walter Roberson am 15 Feb. 2020
inline is recommended against, and has been for close to 20 years. You should use anonymous functions instead.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 15 Feb. 2020
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)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by