![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/996995/image.png)
unit step function to MATLAB
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Faisal Al-Wazir
le 13 Mai 2022
Réponse apportée : Sam Chak
le 13 Mai 2022
i need to plot x(t) and y(t) in matlab but i need to convert them to codes first ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/996935/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/996935/image.png)
0 commentaires
Réponse acceptée
Sam Chak
le 13 Mai 2022
Unit Step function defined for negative time?
clear all; clc
t = -6:0.0001:6;
x = 2.5*(sign(t - -0.5) - sign(t - 0.5))/2;
y = - 2*(sign(t - -3) - sign(t - 0))/2 + 1.5*(sign(t - 0) - sign(t - 3))/2;
subplot(2,1,1)
plot(t, x, 'b', 'linewidth', 1.5)
grid on
xlim([-1.5 1.5])
ylabel('x(t)')
subplot(2,1,2)
plot(t, y, 'r', 'linewidth', 1.5)
grid on
xlabel('t')
ylabel('y(t)')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/996995/image.png)
0 commentaires
Plus de réponses (1)
Abdelrhman Abdelfatah
le 13 Mai 2022
Modifié(e) : Abdelrhman Abdelfatah
le 13 Mai 2022
You need to use Symbolic Math Toolbox
syms x(t) y(t)
x(t) = piecewise((t>-0.5)&(t<0.5),2.5,0)
y(t) = piecewise((t>-3)&(t<0),-2,(t>0)&(t<3),1.5,0)
subplot(2,1,1)
fplot(x)
subplot(2,1,2)
fplot(y)
0 commentaires
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!