plotting equation which is function of 2 variable

1 回表示 (過去 30 日間)
RJS
RJS 2021 年 10 月 6 日
コメント済み: RJS 2021 年 10 月 9 日
I have one equation in terms of 2 variable A,B, I want to plot magnitude vs phase for different value of A and B .
i don't know how to do this . i was trying but it won't work
for A = -20:1:20
for B = -20:1:20
g=(1+i*B)/(1+i*A);
M=20*log10(abs(g)); %Magnitude matrix of Compensator
M = round(M,2);
P =rad2deg(angle(g)); %Phase Matrix of compensator
P = round(P,2);
plot(P,M);
hold on
end
end
trying to plot this figure
then
Find value of A and B for particualr value of phase and magnitude.

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 10 月 6 日
Your code is close. I would take advantage of meshgrid instead of the for loops. Here's what I get making that change. Also, there is no need to round.
[A,B] = meshgrid(-20:1:20);
g=(1+i*B)./(1+i*A);
M=20*log10(abs(g)); %Magnitude matrix of Compensator
P=rad2deg(angle(g)); %Phase Matrix of compensator
plot(P,M,'k')
  8 件のコメント
Cris LaPierre
Cris LaPierre 2021 年 10 月 8 日
編集済み: Cris LaPierre 2021 年 10 月 8 日
Perhaps try adding an assumption that a and b are real.
syms a b real
g=(1+i*b)/(1+i*a);
E = [20*log10(abs(g)) == 10, rad2deg(angle(g)) == 12];
S = vpasolve(E,a,b)
S = struct with fields:
a: 3.1836585625055579563412070062939 b: 10.505085360250508538864040773687
Now test the result to see if it results in the expected M and P values.
A=double(S.a);
B=double(S.b);
g=(1+i*B)./(1+i*A);
M=20*log10(abs(g)) % Should be 10
M = 10.0000
P =rad2deg(angle(g)) % Should be 12
P = 12.0000
RJS
RJS 2021 年 10 月 9 日
Yes i did

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by