Need to create a table with values from a bode plot

조회 수: 4 (최근 30일)
Cody Hodges
Cody Hodges 2023년 3월 2일
댓글: Star Strider 2023년 3월 3일
I have a bode plot and I need to create a three column table. Somthing like:
w phase mag
1 -90 5
10 0 10
100 90 20
It needs to include frequency, magnitude, phase. It can either just be at a particular intervale (for every w = 10^x where x = 1, 2, 3, 4) or at particular values of frequency.
What I have so far:
clear all; clc
% Define System
num = [1 2];
den = [1 10];
sys = tf(num, den);
% Plot Bode
figure(1); clf;
[mag,phase,wout] = bode(sys);
mag = squeeze(mag);
phase = squeeze(phase);
Thank you

채택된 답변

Star Strider
Star Strider 2023년 3월 2일
One approach would be to use the freqresp function with, for example:
w = [1; 10; 100];
then calculate the magnitude and phase from the ‘H’ output with the abs and angle and squeeze functions. Be certain that they are all column vectors, then use the table function with them as the arguments to create the table. Assign the variable names with the 'VariableNames' name-value pair with a cell array of the variable names you want to use.
.
  댓글 수: 2
Cody Hodges
Cody Hodges 2023년 3월 3일
This worked perfectly thank you. Here is the result:
Star Strider
Star Strider 2023년 3월 3일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Plot Customization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by