How do I plot a constant value over multiple different intervals ?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
doubleArray = getaudiodata(rec);
plot(doubleArray);
title('Audio Signal of "Hello World"');
xlabel('Time t');
ylabel('Signal Amplitude x');
hold on %Getting them on same plot
grid on
Squared_Sig = doubleArray.^2; %Squaring all the vaules in the array
b = reshape(Squared_Sig,[],50); %Divides the square signal into 20msec
%chunks by divideing total samples by
%100, each one has 160 elements
partSum = sum(b); % Sum of each of the 100 parts
Average_power = partSum./160;
Here you can see I have the average power for each of the 100 sections of the original signal. How do I create a CT plot of the average power of these sections on the same plot as the original signal ???
3 comentarios
Respuestas (1)
Kaashyap Pappu
el 24 de Oct. de 2019
To plot an overlapping line onto the figure, an x-axis vector would need to be specified and provided to the “plot” function along with the data. The vector would need to have the exact x-values where the corresponding data points should be plotted. The linspace function can help generate an evenly spaced vector.
The following modification to code can achieve this:
doubleArray = getaudiodata(rec)
durationOfSignal = length(doubleArray)*0.02/50; %Specified X-Axis vector using the time values
timeValues = linspace(0,durationOfSignal,length(doubleArray));
plot(timeValues,doubleArray);
title('Audio Signal of "Hello World"');
xlabel('Time t in ms');
ylabel('Signal Amplitude x');
hold on %Getting them on same plot
grid on
Squared_Sig = doubleArray.^2; %Squaring all the vaules in the array
b = reshape(Squared_Sig,[],50); %Divides the square signal into 20msec
%chunks by divideing total samples by
%100, each one has 160 elements
partSum = sum(b); % Sum of each of the 100 parts
Average_power = partSum./160;
xVal = linspace(0,durationOfSignal,length(Average_power)); %X-Axis vector for the Average Power sequence
plot(xVal,Average_power)
Hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!