How can i export datas on the bode plot in SIMULINK?

27 views (last 30 days)
Hello, I need to exprot data from bode plot block in SIMULINK
I made diagram block and run the SIMULINK file but I couldn't get the data based on frequency(x-axis) and magnitude(y-axis).
I only get 'structure' data... but it dosen't include data what i want
To get datas, I tried to make output port on the Bode plot(To Workspace block) and check 'Save data to workspace' on the logging of Bode plot option
How can i export the data from the bode plot in SIMULINK?

Accepted Answer

Arkadiy Turevskiy
Arkadiy Turevskiy on 14 Dec 2016
When you run the model with Bode Plot block, with "save data to workspace" enabled, you get a variable sys, or whatever name you specified for it. sys is a structure, like you said. It contain frequency response information in the form of state-spaces matrices A,B,C,D as well as block name and snapshot time when linearization was computed.
To access state space matrices type
sys.values
To get magnitude, phase and frequency data from the bode plot:
[mag,phase,w]=bode(sys.values);
Recreate Bode plot:
semilogx(squeeze(w),20*log10(squeeze(mag)))
subplot(211)
semilogx(squeeze(w),20*log10(squeeze(mag)))
subplot(212)
semilogx(squeeze(w),squeeze(phase))

More Answers (0)

Community Treasure Hunt

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

Start Hunting!