Creating the discrete-time graph of a recorded audio signal

22 views (last 30 days)
Hello!
I am a second year engineering major. I have not yet studied anything that remotely resembles MATLAB but as an exercise i have been given the task of displaying a given audio signal in a discrete-time graph and after that finding its fourier transform. The problem is that all that should be done in MATLAB. I have the audio signal as a recording. The exercise requires that i display the first 80 samples with the sampling rate being up to me.
From what i could gather i created this, but unfortunately it doesn't work and to be honest I don't really understand what I am doing. Can someone offer a little help?
Thanks in advance!
Fs = 4000; Channels = 1; bits = 16;
[data, fs] = audioread("/MATLAB Drive/recordingX.wav");
X = getaudiodata(data);
n = 0:1/Fs:(length(X)-1)/Fs;
plot(n,X);

Accepted Answer

Mathieu NOE
Mathieu NOE on 25 May 2023
hello
no panic !
if you have records in wav format , you only need audioread to get your data
getaudiodata is not needed here (read the doc if you have time though)
as a wav file can have one or multiple channes , also look at the end how you can either plot one channel or all channels on the same graph
hope it helps !
Fs = 4000; Channels = 1; bits = 16;
[data, fs] = audioread("/MATLAB Drive/recordingX.wav");
[samples,channels] = size(data);
% plot the k first samples
k = 80;
n = 1:k;
% plot(n,data(n,:)); % will plot all channels
plot(n,data(n,1)); % will plot first channel

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!