Plot unit step function
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Corinne Dale
il 3 Ott 2018
Commentato: Star Strider
il 19 Set 2023
I'm trying to plot the signal u(t)-u(t-1) without heaviside in MATLAB. I've tried to use the if loop but couldn't figure it out.
Risposta accettata
Star Strider
il 3 Ott 2018
You can use a ‘logical indexing’ approach:
ustp = @(t) +(t>0); % Simple Unit Step Function
t = linspace(-5, 5);
figure
plot(t, ustp(t)-ustp(t-1))
grid
I will let you figure out how it works.
3 Commenti
Vicky
il 19 Set 2023
Can you explain how you wrote "@(t) +(t>0)"? It worked perfectly but I'm unsure what the @ is doing here. Thank you so much!
Star Strider
il 19 Set 2023
@Vicky — That is an anonymous function. It works the same way other functions do, and can be called similarly. The ‘@’ creates its function handle.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Pie Charts in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!