Plot symbolic expresion dependent on one parameter on complex plane, making the parameter take a range of values.

6 ビュー (過去 30 日間)
Greetings,
I have the following expresion:
syms N A a dw;
N=subs(4/A^2/pi*(sqrt(A^2-a^2)-1i*a),a,1)
N = 
I'd like to make the parameter A variate from 1 to positive inf and plot the resulting complex number on the nyquist plot:
nyquist(tf(pi,[1 2 0]));
My first tought was to use subs in order to get a vector but I was wondering if the symbolic toolbox has something in order to get the result to inf.
Thanks!

回答 (1 件)

Gayatri Rathod
Gayatri Rathod 2023 年 4 月 3 日
Hi naga,
Here are a few approaches to make the parameter A vary from 1 to positive inf:
  1. MATLAB has a function called limit that can be used to find the limit of a symbolic expression as a variable approaches a specific value or infinity.
  • In your case, you can use the limit function to find the limit of N as A approaches infinity. Here's an example code snippet that should work:
N = 4/A^2/pi*(sqrt(A^2-a^2)-1i*a);
N_inf = limit(N, A, inf);
nyquist(tf(pi, [1, 2, 0])); % plot the Nyquist diagram for the transfer function
hold on;
plot(real(N_inf), imag(N_inf), 'ro'); % add a red dot to indicate the limit point
  • Here, N is your symbolic expression and N_inf is the limit of N as A approaches infinity. The nyquist function is used to plot the Nyquist diagram for the transfer function tf(pi, [1, 2, 0]). plot is used to add a red dot at the limit point. The hold on command is used to prevent the Nyquist diagram from being cleared before the dot is added.
  • Note that the limit of N as A approaches infinity depends only on the highest order term in the expression.
  • 2.Symbolic Math Toolbox in MATLAB has a function called "symfun" that allows you to create symbolic functions with variables that can vary over a range. You can use this function to create a symbolic function for your expression and then plot it using the "nyquist" function.
  • Here's an example code snippet that shows how to use "symfun" to create a function for your expression and then plot it over a range of values for A:
N = 4/A^2/pi*(sqrt(A^2-a^2)-1i*a);
N_fun = symfun(N, A);
nyquist(N_fun(A), [1, inf]);
  • Here, "N_fun" is a symbolic function for your expression with "A" as the input variable. The nyquist function is then called with "N_fun(A)" as the first argument. The second argument to nyquist is a range of values for "A" that you want to plot over, which in this case is from 1 to positive infinity.
You can read more about the limit, plot, symfun functions and hold on from the following documentations: limit function, plot function, symfun function, hold on function.
Hope it helps!  
Regards,
Gayatri Rathod

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by