COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Help in plotting a square wave using Syms

• Follow

```syms t
f = @(t) heaviside(t+0.5)-heaviside(t-0.5);
hold on
for n = -10 : 1 : 11;
e = (-1)^n;
ezplot(e*f(t-n));
end
hold off
grid on
ylim([-3,3]),xlim([-10,10]);

I do not get a correct plot using this !!!
Thanks !!
```
 0

```On 2/26/2011 7:30 AM, Animesh Pandey wrote:
> syms t
> f = @(t) heaviside(t+0.5)-heaviside(t-0.5);
> hold on
> for n = -10 : 1 : 11;
>      e = (-1)^n;
>      ezplot(e*f(t-n));
> end
> hold off
> grid on
> ylim([-3,3]),xlim([-10,10]);
>
> I do not get a correct plot using this !!!
> Thanks !!

ezplot( heaviside(t+0.5)-heaviside(t-0.5),[-1 1])

--Nasser
```
 0

```syms t
f = @(t) heaviside(t+0.5)-heaviside(t-0.5);
hold on
for n = -10 : 1 : 11;
e = (-1)^n;
ezplot(e*f(t-(n)), [-10,10]);
end
hold off
grid on
ylim([-3,3]),xlim([-10,10]);

The plot was better ... but there is a blue line on the x axis that is under every square wave, which should not be there !!! It was not looking like a wave but like many rect(t)'s on a long line !!!!
thnx
```
 0

2 Replies
583 Views

Similiar Articles:

7/25/2012 9:53:20 PM