Hello Jojo,
The wavrecord function in MATLAB (note that it has been deprecated and replaced by audiorecorder in newer versions) records audio data and returns it as an array. Here is how to interpret the axes:
Y-Axis (Audio Signal Values):
- Unit: The values on the y-axis represent the amplitude of the audio signal. These are typically normalized floating-point numbers ranging from -1 to 1, representing the relative amplitude of the audio waveform.
- Interpretation: These values are dimensionless and do not directly correspond to physical units like voltage or power density. They represent the sampled audio waveform's amplitude.
X-Axis (Sample Index):
- Unit: The x-axis represents the sample index, not frequency. When you use plot(y), you are plotting the amplitude of each audio sample against its index in the array.
- Interpretation: The x-axis values are simply the indices of the samples, ranging from 1 to n, where n is the number of samples recorded. To convert these indices to time, you can divide by the sampling frequency Fs, resulting in units of seconds.
Example Code for Plotting:
recObj = audiorecorder(Fs, nBits, nChannels);
recordblocking(recObj, duration);
disp('End of recording.');
y = getaudiodata(recObj);
t = (0:length(y)-1) / Fs;
xlabel('Time (seconds)');
This will give the following as the output:
Correlation in MATLAB:
The corrcoef function in MATLAB computes the correlation coefficients between two or more variables. The correlation coefficient is a measure of the linear relationship between variables.
Formula: The correlation coefficient between two variables X and Y is calculated as: where:
- is the covariance between X and Y.
- and are the standard deviations of X and Y.
Usage: R = corrcoef(X) returns a matrix R of correlation coefficients, where R(i,j) is the correlation coefficient between the i-th and j-th variables.
Example Code for Correlation:
Y = 2 * X + randn(100, 1);
disp('Correlation Coefficient Matrix:');
The result of this code is:
Correlation Coefficient Matrix:
1.0000 0.9287
0.9287 1.0000
You can modify the code according to your requirements.
I hope this helps!