"ravirevolt" <ravirevolt@yahoo.co.in> wrote in message
news:VdCdnSBiBPjsO1veRVn-vA@giganews.com...
>
> i've done my sampling like this is it correct ?
Is this associated with your previous post about simulating a digital
beamformer?
> i'm sampling a 3GHz signal;
is that your signal bandwidth or signal center frequency?
> design for 8 bit sample
>
> double array[256]; //8 bit so
have you reserved space for a 256 element double precision vector called
array here? Why not give it a descriptive name and insert a comment that
helps you remember what you are physically representing?
> double amplitude=100;
You seem to have arbitrarily set the peak amplitude = 100. A comment as to
why you did this might help you interpret your code at a later date.
now load up 256 elements with something very close to zero ? sign will
alternate but maybe not that reliably, why are you doing this? What does
your i index represent?
> dc.setpixel(i,array[i],RGB(255,0,0));
produce a short monochrome line on a display? what happens if array[2]
is -ve by the way?
> }
>
> plz guide me and explain if i'm wrong
How can we? - you don't say what you are trying to do.
Best of Luck - Mike
Reply by Bhaskar Thiagarajan●January 12, 20062006-01-12
"ravirevolt" <ravirevolt@yahoo.co.in> wrote in message
news:VdCdnSBiBPjsO1veRVn-vA@giganews.com...
>
> i've done my sampling like this is it correct ?
> i'm sampling a 3GHz signal;
> design for 8 bit sample
>
> double array[256]; //8 bit so
> double amplitude=100;
> double frequency=3000000000;
> for(int i=0;i<256;i++)
> {
> array[i]=amplitude*sin(2*PI*frequency*i/(2*3000000000));
> dc.setpixel(i,array[i],RGB(255,0,0));
> }
>
> plz guide me and explain if i'm wrong
Since you haven't given too much background information, I'll just comment
on what you've shown us...
What does 8 bit samples have to do with double array[256]? It appears you
are doing a simulation of some kind and it appears you have double precision
arithmetic. If you want 8 bit samples, you have to convert your array[i] to
say short ints (but that's usually 16 bits), so you'll need to do more
conversions to ensure they have only 8 bit data in them.
You sampling frequency fs here is 2*fin where fin is your sinusoid'd
frequency. I'd recommend you use fs = 4*fin or higher for your simulation
purposes (as well as in a real system). The Nyquist theorem mandates an fs >
2*fin.
Also, your time index (i) in your sine computation should be different from
your loop index.
Cheers
Bhaskar
Reply by ravirevolt●January 12, 20062006-01-12
i've done my sampling like this is it correct ?
i'm sampling a 3GHz signal;
design for 8 bit sample
double array[256]; //8 bit so
double amplitude=100;
double frequency=3000000000;
for(int i=0;i<256;i++)
{
array[i]=amplitude*sin(2*PI*frequency*i/(2*3000000000));
dc.setpixel(i,array[i],RGB(255,0,0));
}
plz guide me and explain if i'm wrong