Solving math by equal

2 views (last 30 days)
cong
cong on 28 Apr 2025
Commented: Sam Chak on 5 May 2025
Solve math problems in 2 ways
1.Use MATLAB
2 Relieve your hands manually
someone please help me
  5 Comments
Torsten
Torsten on 28 Apr 2025
Do you know about the MATLAB functions "tf" and "margin" ? If not, take a look at them: they should solve your problem.

Sign in to comment.

Accepted Answer

Sam Chak
Sam Chak on 29 Apr 2025
In my previous answer, the margin() function cannot accurately determine the phase margin because there are three gain crossovers between 1 rad/s and 2 rad/s, and the function only returns the margin at the frequency with the smallest stability margin. You need to zoom into the gain curve to see this clearly. In this situation, you should use the allmargin() function instead. To find the phase margin by hand, use this formula:
format long g
s = tf('s');
%% Case 1: manually find it!
K = 3.45850428040268842444505;
%% Case 2: matlabcentral/answers/1724785-calculation-of-phase-margin
% w = 1.49109560603497592889965; % crossover frequency
% K = sqrt(w^4 + (w^2)*(4 - w^2)^2) % gain formula derived from crossover frequency
%% Plant
G = K/(s*(s^2 + 1*s + 4));
%% Find the Phase margin using margin
figure
margin(G), grid on, grid minor
%% Zoom in to look at the gain curve around the phase crossover frequency
figure
bode(G, linspace(1.26, 1.76, 1000)), grid on, grid minor
% Estimate the Phase margin between 1.4 and 1.6 rad/s
allmargin(G, Focus=[1.4, 1.6])
ans = struct with fields:
GainMargin: [1x0 double] GMFrequency: [1x0 double] PhaseMargin: 49.9948861578639 PMFrequency: 1.49108061155173 DelayMargin: 0.58519664587845 DMFrequency: 1.49108061155173 Stable: 1
%% Find the Phase margin using allmargin
allmargin(G)
ans = struct with fields:
GainMargin: 1.1565693362491 GMFrequency: 2 PhaseMargin: [58.2696543464024 50.0000000000002 31.2191998344823] PMFrequency: [1.34866793694202 1.49100344855771 1.71978818898325] DelayMargin: [0.754075406174253 0.585286792489529 0.316828450410466] DMFrequency: [1.34866793694202 1.49100344855771 1.71978818898325] Stable: 1
  2 Comments
cong
cong on 5 May 2025
Cảm ơn bạn
Sam Chak
Sam Chak on 5 May 2025
You're welcome, @cong! If you find the new solution helpful, please consider clicking 'Accept' ✔ on the answer and voting 👍 for it. Your support is greatly appreciated!

Sign in to comment.

More Answers (1)

Sam Chak
Sam Chak on 28 Apr 2025
You can assign a value to K, compute the transfer function G(s), and then use the margin(G) command to find the phase margin (Pm). Here is the code snippet for the three steps:
However, I prefer not to provide advanced code at this stage, as I believe you may not yet be prepared for it. Anyhow, the real problem is, Can you really find the static gain K such that the Phase margin is exactly 50°?
s = tf('s');
%% When K = 3.44
K = 3.44;
G = K/(s*(s^2 + 1*s + 4));
figure
margin(G); grid on, grid minor
%% When K = 3.45
K = 3.45;
G = K/(s*(s^2 + 1*s + 4));
figure
margin(G); grid on, grid minor
  2 Comments
cong
cong on 28 Apr 2025
I need a paper solution. Handwriting
Sam Chak
Sam Chak on 28 Apr 2025
I no longer memorize the formula for calculating the phase margin by hand. Therefore, I rely on the MATLAB Control System Toolbox. You should consult your Control Professor, as they are compensated to teach students, not the other way around.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!