From: Mane ne on
Hi,

I'm told it's possible to run the following code without a loop straight into the vectors. I'm sure i used to know how to do this (using colons) but i don't think I remember, can anyone tell me a simple solution? Thanks!!

for n=1:SR

f2(n)=f*(1+xi*beta*n/SR);
x(n)=eps*r*sin(2*pi*f2(n)*n/SR)*exp(-beta*n/SR);

end

I've been trying things like this:

f2(1:SR)=f*(1+xi*beta*1:1/SR);
x(1:SR)=eps*r*sin(2*pi*f2(1:SR)*1:1/SR)*exp(-beta*1:1/SR);

Which i know seems wrong and gives me an "improper assignment" error. :(

Again, many thanks.
From: Walter Roberson on
Mane ne wrote:
> Hi,
>
> I'm told it's possible to run the following code without a loop straight
> into the vectors. I'm sure i used to know how to do this (using colons)
> but i don't think I remember, can anyone tell me a simple solution?
> Thanks!!
>
> for n=1:SR
>
> f2(n)=f*(1+xi*beta*n/SR);
> x(n)=eps*r*sin(2*pi*f2(n)*n/SR)*exp(-beta*n/SR);
> end
>
> I've been trying things like this:
>
> f2(1:SR)=f*(1+xi*beta*1:1/SR);

Close.

f2(1:SR)=f*(1+xi*beta*(1:SR)/SR);

> x(1:SR)=eps*r*sin(2*pi*f2(1:SR)*1:1/SR)*exp(-beta*1:1/SR);
x(1:SR)=eps*r*sin(2*pi*f2(1:SR).*(1:SR)/SR).*exp(-beta*(1:SR)/SR);


Note: there are cleaner ways to write this...
From: Mane ne on
Walter Roberson <roberson(a)hushmail.com> wrote in message <i44es8$514$2(a)canopus.cc.umanitoba.ca>...
> Close.
>
> f2(1:SR)=f*(1+xi*beta*(1:SR)/SR);
>
> > x(1:SR)=eps*r*sin(2*pi*f2(1:SR)*1:1/SR)*exp(-beta*1:1/SR);
> x(1:SR)=eps*r*sin(2*pi*f2(1:SR).*(1:SR)/SR).*exp(-beta*(1:SR)/SR);
>
>
> Note: there are cleaner ways to write this...

That's great!! Cheers. Yeah I know i can probably tighten it up more, I just wanted to get that loop out first to cut down running time :)