Sam Adams
Sam Adams

Reputation: 25

Should I put sin or cos to represent a sinusoidal signal?

We were asked in an exercise to create a sinusoidal signal of 0.8 seconds with an amplitude of 1 and frequency equal to 100 Hz sampled at 1000 Hz, but in the answer I found:

A=1;fs=100;fe=1000;
te=1/fe;
t=0:te:0.8;
s=A*cos(2*pi*fs*t);
plot(s);

And in another exercise: write a script for a sinusoidal signal of amplitude 1 and 200kHz frequency, over a period N = 64, sampled at 150 kHz, the answer was :

%Signal
fs=200;N=64;
ts=1/fs;
A=1;
subplot(211);
t=0:0.00001:N*ts;
x=sin(2*pi*t*fs);
plot(t,x);
title('signal sinusoidal');

%Sampling
Fe=input('Fe=');
te=1/Fe;
t1=0:te:N*te;
xe=sin(2*pi*t1*fs);
subplot(212);
stem(t1,xe);

I'm so confused. When to put a sin and when to put a cosine? My question is why they put a cosine instead of a sin? Is there some kind of rule behind it?

Thanks in advance.

Upvotes: 0

Views: 211

Answers (1)

Luis Mendo
Luis Mendo

Reputation: 112749

Any of those choices qualifies as a sinusoid. Note that

cos(2*pi*fs*t)

is the same as

sin(2*pi*fs*t + pi/2)

In general,

sin(2*pi*fs*t + phi)

is a sinusoid for any choice of phi (as would be cos(2*pi*fs*t + phi)) . phi is the initial phase (or simply phase) of the sinusoid. To know which phi to use you would need an additional condition.

Upvotes: 4

Related Questions