# Trying to plot the multiplication of triangular and unit step signal.

3 visualizzazioni (ultimi 30 giorni)
Tasin Nusrat il 14 Set 2022
Risposto: Walter Roberson il 14 Set 2022
I am trying to plot a signal x(t) where
x(t)=0 for t<0
x(t)=0 for t>=1
x(t)=-t+1 for 0≤t≤1
I write the code as follows:
t=-5:5
x(t)= 0*(t<0)+(-t+1).*((0<=t)&&(t<=1))+0*(t>=1);
but its not showing the correct plot. I think the problem is with writing x(t)=-t+1 for 0≤t≤1 condition. I am expecting the plot to be like
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Walter Roberson il 14 Set 2022
t = -5:.01:5
t = 1×1001
-5.0000 -4.9900 -4.9800 -4.9700 -4.9600 -4.9500 -4.9400 -4.9300 -4.9200 -4.9100 -4.9000 -4.8900 -4.8800 -4.8700 -4.8600 -4.8500 -4.8400 -4.8300 -4.8200 -4.8100 -4.8000 -4.7900 -4.7800 -4.7700 -4.7600 -4.7500 -4.7400 -4.7300 -4.7200 -4.7100
x = (1-t) .* (0<=t & t<=1);
stairs(t, x)
axis equal
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Descriptive Statistics 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!

Translated by