From: Elizabeth on
I'm trying to plot the following in the upper left hand corner of a subplot, but I can't figure out how to plot it!
t=0:001:1
s=(1:1001)
for f=0:5:100
s + sin(2*pi*f*t)
end

Any suggestions on what I'm doing wrong? When i type plot(t,s) I get a straight line and I need a crazy sine wave. Thanks!
liz
From: jrenfree on
On Sep 8, 4:14 pm, "Elizabeth " <ebroc...(a)gmail.com> wrote:
> I'm trying to plot the following in the upper left hand corner of a subplot, but I can't figure out how to plot it!
> t=0:001:1
> s=(1:1001)
> for f=0:5:100
> s + sin(2*pi*f*t)
> end
>
> Any suggestions on what I'm doing wrong? When i type plot(t,s) I get a straight line and I need a crazy sine wave.  Thanks!
> liz

First off, when you define t, do you want it to increment by 0.001 or
by 1? Because

t = 0:001:1

means you're incrementing by 1 and t is thus equal to [0 1]. So I
think you forgot your period.

Secondly, look at what sin(2*pi*f*t) gives you. It's a sine wave that
goes from -1 to 1. Then you're adding 's' to that sine wave, where s
goes from 1 to 1001. Your variable s is going to dominate that signal
and you won't see much of the sine wave.
From: Elizabeth on
jrenfree <jrenfree(a)gmail.com> wrote in message <8ed339e1-2dbb-4452-9edf-eda3f6703df8(a)r24g2000prf.googlegroups.com>...
> On Sep 8, 4:14?pm, "Elizabeth " <ebroc...(a)gmail.com> wrote:
> > I'm trying to plot the following in the upper left hand corner of a subplot, but I can't figure out how to plot it!
> > t=0:001:1
> > s=(1:1001)
> > for f=0:5:100
> > s + sin(2*pi*f*t)
> > end
> >
> > Any suggestions on what I'm doing wrong? When i type plot(t,s) I get a straight line and I need a crazy sine wave. ?Thanks!
> > liz
>
> First off, when you define t, do you want it to increment by 0.001 or
> by 1? Because
>
> t = 0:001:1
>
> means you're incrementing by 1 and t is thus equal to [0 1]. So I
> think you forgot your period.
>
> Secondly, look at what sin(2*pi*f*t) gives you. It's a sine wave that
> goes from -1 to 1. Then you're adding 's' to that sine wave, where s
> goes from 1 to 1001. Your variable s is going to dominate that signal
> and you won't see much of the sine wave.



Even when having s=0 I still see no image, we need to create a signal that contains frequencies 0:5:100, with a magnitude of each frequency of 1, and the sampling frequecy of 1000HZ