clear all
syms s w
G = 1/((s)*(s+1)*(s+2)); %transfer function
G_w = subs(G,s,j*w);
W= [-100:0.01:100]; %[min_range:step size:max_range]
nyq = eval(subs(G_w,w,W));
x = real(nyq)
y = imag(nyq)
plot(x,y)
I can't seem to run this code and it keeps displaying error in line 100++ where I've only less than 20 lines.
Error using symengine (line 59)
Division by zero.
Error in sym/subs>mupadsubs (line 139)
G = mupadmex('symobj::fullsubs',F.s,X2,Y2);
Error in sym/subs (line 124)
G = mupadsubs(F,X,Y);
Error in nyquist2 (line 8)
nyq = eval(subs(G_w,w,W)); %replace W with w in equation G_w
This are the errors shown, any expert could help me in this ?
The error is because you are computing
G_w
using the arrayW
and this array contains the value0
resulting in a division by zero and therefore the error.What you can do to get around this, is to replace the
0
inW
witheps
.As a side-note, the error isn't complaining about an issue with line 100+ of your code, but rather the stack trace is stating that the error actually originated from within a function that you're calling
The stack trace is ordered from where the error occured to the code that you called to create it