How can I use data from BODE plot and use it on a MATLAB figure window using System Identification Toolbox 7.4.3 (R2011b) ?

11 views (last 30 days)
I use the following data and MATLAB functions to plot the PSD from the input data:
xn = rand(3001, 1); % Input signal
n = 3001;
NFFT = 2^nextpow2(n)+3;
Ts = 0.001;
Fs = 1/Ts; % Sample Frequency
h = spectrum.welch('Hann',NFFT/2,0.67);
Hpsd=psd(h,xn,'Fs',Fs,'ConfLevel',0.95);
plot(Hpsd); % works fine
% Now I would like to edit data plotted as below
H=(10.^(Hpsd/20))^2;
plot(H)
I am getting an error from last two lines in my code.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Mar 2012
The variable 'Hpsd' is not a variable, but, an object.
Hence the PLOT function called on the Object internally calls the Data property of this object and the plot is as expected with units dB/Hz.
In order to extract the data instead of using the PLOT function, use the following approach:
- Get a list of properties of the 'Hpsd' object. This is done with the following step:
get(Hpsd)
- From the property list, collect the values i.e. the data that you would like to use for conversion. The property that I am referring to is 'Data' in the Y-axis and 'Frequency' in the X-axis. This is done in the following step:
y = Hpsd.Data;
x = Hpsd.Frequencies;
- You can use the values 'y' and 'x' to be plotted on a separate MATLAB figure, as done in the following step:
plot(x, 10*log10(y), 'r');

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2011b

Community Treasure Hunt

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

Start Hunting!