Generating a 6 second sine wave?

33 Ansichten (letzte 30 Tage)
Dick Rusell
Dick Rusell am 7 Okt. 2014
Kommentiert: Akpabio Ekpewoh am 11 Jul. 2019
I'm supposed to generate a 6 seconds long sine wave that has amplitude of 1.0, frequency of 400Hz at a 8KHz sampling frequency, but I'm not sure how to control how long the wave lasts for.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 7 Okt. 2014
f=400
Amp=1
ts=1/8000;
T=6
t=0:ts:T;
y=sin(2*pi*f*t);
plot(t,y)
  3 Kommentare
Image Analyst
Image Analyst am 26 Mär. 2018
Add a function line:
function [t, y] = PlaySound()
f=100;
Amp=10;
fs = 44100;
ts=1/44100;
T=10;
t=0:ts:T;
y=sin(2*pi*f*t);
sound(y,fs)
Mohamad
Mohamad am 4 Apr. 2019
f=400
Amp=1
ts=1/8000;
T=6
t=0:ts:T-ts; % I modified this line to make signal duration 6 seconds
y=sin(2*pi*f*t);
plot(t,y)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 7 Okt. 2014
Hint: 6 seconds at 8000 times per second means that the vector (row array) will be 48000 elements long.
sineWave = sin(2*pi*freq*timeVector);
See if that's enough hints.
  3 Kommentare
Dick Rusell
Dick Rusell am 10 Okt. 2014
Is there a way to zoom outt? Because I get a blue box when I plot it from the frequency.
Akpabio Ekpewoh
Akpabio Ekpewoh am 11 Jul. 2019
Yes, just use the icons on the top of the plot

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by