how to find roots of equations

6 views (last 30 days)
saman ahmadi
saman ahmadi on 18 Sep 2020
Commented: saman ahmadi on 18 Sep 2020
Hi. I want to extract roots(w) of below two equation(equations are detA and detB). The roots of equation are with respect to N(w(N)), i want to plot(N,w), how can i do this? thank you
syms w N
k1=70;
k2=200;
m1=0.1;
m2=0.064;
m3=0.04;
r=0.25
M1=(m2+m3)/m1;
M2=m2/m1;
K=k2/k1;
wn1=(sqrt(k1/m1))/(2*pi);
wn2=(sqrt(2*k2/m3))/(2*pi);
A=[-(1+M1)*(w/wn1)^2+2-2*cos(pi) -M2*(w/wn1)^2 -(M1-M2)*(w/wn1)^2;-(w/wn1)^2 -N*(w/wn1)^2+(2*K)/M2 -K/M2;-(w/wn2)^2 -0.5 1-(w/wn2)^2];
detA=det(A)
B=[-(1+M1)*(w/wn1)^2+2-2*cos(0) -M2*(w/wn1)^2 -(M1-M2)*(w/wn1)^2;-(w/wn1)^2 -N*(w/wn1)^2+(2*K)/M2 -K/M2;-(w/wn2)^2 -0.5 1-(w/wn2)^2];
detB=det(B)
  2 Comments
BOB MATHEW SYJI
BOB MATHEW SYJI on 18 Sep 2020
How can detA and detB be two equations if they are not equated to anything. Like, is it detA=0 and detB=0.
saman ahmadi
saman ahmadi on 18 Sep 2020
phrases in front of detA and detB are equal to zero

Sign in to comment.

Answers (1)

Jeremy Perez
Jeremy Perez on 18 Sep 2020
Hi,
Adapt the lines as you want:
1- Get the roots
C = coeffs(detA,w) % w polynom coeffs
r = eval(roots(C)) % roots
2- Replace the symbolic variable in the symbolic function to make the plot function
nRoot = 1; %first root
f = @(x) real(eval(subs(r(nRoot),N,x))) %replace sym N by a num value x
g = @(x) imag(eval(subs(r(nRoot),N,x)))
3-Plot:
x = -1:0.1:1 %begin:step:end
y = arrayfun(f,x)
figure()
plot(x, y)
Hope it helps,

Community Treasure Hunt

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

Start Hunting!