multiplying audio signal by using Matlab

I have an audio signal ( of my voice ) .However,I want to multiply it by cosine function.
t=[1:1000];
n=cos(2*pi*fc*t);
[y fs]=audioread('message.wav');
How can I do that ?

 Akzeptierte Antwort

Star Strider
Star Strider am 24 Mär. 2020

0 Stimmen

The cosine signal must be the same size as ‘y’.
One way to define it as such:
t = linspace(0, 1, fs);
Then create the cosine funciton to be what you want.
Try this:
t = linspace(0, 1, fs);
fc = 440;
n=cos(2*pi*fc*t).';
y_new = y .* n;
sound(y_new,Fs)

6 Kommentare

Gentle EE
Gentle EE am 24 Mär. 2020
It gives me an error massage saying
Matrix dimensions must agree. in y_new = y .* n;
Try this:
y_new = bsxfun(@times, y, n);
The size of ‘y’ was not specifically stated.
Gentle EE
Gentle EE am 24 Mär. 2020
oh sorry I'm pretty new to the matlab
The size of ‘y’ is   360856 2 
and for this command y_new = bsxfun(@times, y, n); it gives me an Error message.
Non-singleton dimensions of the two input arrays must match each other.
sorry to bother you
Then define ‘t’ as:
t = linspace(0, 1, size(y,1));
That will equalise their lengths. You will need to define your cos call correctly to produce the result you want.
One possibility that may make that easier:
t = linspace(0, 1, size(y,1))/fs;
Experiment to get the result you want.
Remember that the cos call must produce a column vector.
The easiest way to do that is to use the (:) subscript convention to force ‘t’ to be a column vector:
n=cos(2*pi*fc*t(:));
This assumes that ‘fc’ is a scalar.
Gentle EE
Gentle EE am 24 Mär. 2020
Thank you so much !
Star Strider
Star Strider am 25 Mär. 2020
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by