简体   繁体   English

在 MATLAB 中为 Bode plot 定义传输 function 时出现问题

[英]Problem with defining a transfer function for Bode plot in MATLAB

I am trying to tune a PID controller using Matlab(not Simulink because I am learning/uni coursework).我正在尝试使用 Matlab 调整 PID controller(不是 Simulink,因为我正在学习/uni 课程)。 1. Summarize the problem: 1、总结问题:

  • So, I have a transfer function of a system for which there are phase margin requirement that needs to met所以,我有一个需要满足相位裕度要求的系统的传输 function
  • In order to find the phase advance part of the PID I need to solve a bunch of equations to plot a Bode plot using the variables calculated为了找到 PID 的相位超前部分,我需要使用计算的变量求解 plot 和 Bode plot 的一系列方程

2.Describe what I've tried 2.描述我尝试过的

  • I tried to replace the tf([num],[den]) with real numbers but that is not feasible as it defeats the purpose of doing this, I want Matlab to calculate the GR and frequency and substitute that into the tf我试图用实数替换tf([num],[den])但这不可行,因为它违背了这样做的目的,我希望 Matlab 计算 GR 和频率并将其代入 tf

Problem问题

错误Full_Code: https://drive.google.com/file/d/1sWUnvvye_RBXGL8-nWq___3F5UDmDOoG/view?usp=sharing Full_Code: https://drive.google.com/file/d/1sWUnvvye_RBXGL8-nWq___3F5UDmDOoG/view?usp=sharing

Minimum reproducible code example:最小可重现代码示例:

clearvars;clc;clearAllMemoizedCaches;clear

syms s w 

%--------------TF of the aircraft

G(s)= (160*(s+2.5)*(s+0.7))/((s^2+5*s+40)*(s^2+0.03*s+0.06));

k= 8;  % selected k value range 4<k<8

Max_PA=asind((k-1)/(k+1)); % computes max phase advance

Centre_dB= 20*log10(sqrt(k)); % computing centre gain in dB

Poi= -120-Max_PA  % looking for Point of interest(Poi)

tf_int= subs(G(s),1j*w); %intermediate transfer function

eqn= atan2d(imag(tf_int),real(tf_int))==Poi; % solve for w at Poi


% computing crossover freq(wc)

wc= vpasolve(eqn,w); % find exactly the wc at Poi

GR=20*log10(abs(subs(tf_int,w,wc))); % find the gain at at wc

Kpa= 10^((GR-Centre_dB)/20);

ti= 1/(sqrt(k)*wc); % computing Kpa and ti

num1= [Kpa*k*ti,Kpa];

den2= [ti,1];

PA= tf(num1,den2) %PA tf defined

Yo are trying to input non-numerical (symbolic numers) values into tf , which only accepts numerical arrays.哟正在尝试将非数字(符号数字)值输入tf ,它只接受数字 arrays。 You can convert them to that with double()您可以使用double()将它们转换为

PA= tf(double(num1),double(den2)) %PA tf defined

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM