How do I plot a constant value over multiple different intervals ?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Kaashyap Pappu
am 24 Okt. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Waveform Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!