my program is not stop. please help

23 次查看(过去 30 天)
clc
syms c h k
c11=106.8;
c33=54.57;
c13=9.68;
c15=0.28;
c35=-1.69;
c55=25.05;
r1=2727;
l=2.46;
u=5.66;
r2=7800;
i=sqrt(-1);
n=2.54;
a=(c33*c55);
b=(c35^2);
d=(c15*c33);
e=(c13*c35);
f=(c33+c55);
g=(c15*c35);
j=(c11*c33);
m=(c13^2);
o=(c13*c55);
p=(c55+c11);
q=((c11*c55)-c15^2);
r=(c15+c35);
t=(c11*c35-c13*c15);
a0=a-b;
a1=-2*i*(d-e);
a2=f*r1*(c^2)-2*g-j+m+2*o;
a3=-2*i*(r*r1*(c^2)-t);
a4=(r1^2)*(c^4)-p*r1*(c^2)+q;
s=[a0 a1 a2 a3 a4];
root=roots(s);
s1=root(1);
s2=root(2);
s3=root(3);
s4=root(4);
m1=-((c55)*(s1^2)-2*i*(c15)*(s1)+r1*(c^2)-(c11))/((c35)*(s1^2)-i*(c13+c55)*(s1)-(c15));
m2=-((c55)*(s2^2)-2*i*(c15)*(s2)+r1*(c^2)-(c11))/((c35)*(s2^2)-i*(c13+c55)*(s2)-(c15));
m3=-((c55)*(s3^2)-2*i*(c15)*(s3)+r1*(c^2)-(c11))/((c35)*(s3^2)-i*(c13+c55)*(s3)-(c15));
m4=-((c55)*(s4^2)-2*i*(c15)*(s4)+r1*(c^2)-(c11))/((c35)*(s4^2)-i*(c13+c55)*(s4)-(c15));
alpha=sqrt((l+2*u)/r2);
beta=sqrt(u/r2);
b0=(n^2)*((beta^2)/alpha^2);
b1=(n^2)*((1-((beta^2)/(alpha^2))^2))+n*(((c^2)/(alpha^2))-n)+n*((beta^2)/(alpha^2))*((c^2)/(beta^2)-n);
b2=((beta^2)/(alpha^2))*((c^2)/(alpha^2)-n)*((c^2)/(beta^2)-n);
p=[b0 0 b1 0 b2];
proot=roots(p);
p1=proot(1);
p2=proot(2);
p3=proot(3);
p4=proot(4);
n1=(((c^2)/(alpha^2))-n+n*((beta^2)/(alpha^2))*(p1^2))/(i*n*(1-((beta^2)/(alpha^2))*p1));
n2=(((c^2)/(alpha^2))-n+n*((beta^2)/(alpha^2))*(p2^2))/(i*n*(1-((beta^2)/(alpha^2))*p2));
K1=i*(c15)-m1*s1*(c35)+(i*m1-s1)*(c55);
K2=i*(c15)-m2*s2*(c35)+(i*m2-s2)*(c55);
K3=i*(c15)-m3*s3*(c35)+(i*m3-s3)*(c55);
K4=i*(c15)-m4*s4*(c35)+(i*m4-s4)*(c55);
K5=i*(c13)-m1*s1*(c33)+(i*m1-s1)*(c35);
K6=i*(c13)-m2*s2*(c33)+(i*m2-s2)*(c35);
K7=i*(c13)-m3*s3*(c33)+(i*m3-s3)*(c35);
K8=i*(c13)-m4*s4*(c33)+(i*m4-s4)*(c35);
e1=exp(k*s1*h);
e2=exp(k*s2*h);
e3=exp(k*s3*h);
e4=exp(k*s4*h);
A=[1 1 1 1 -1 -1; m1 m2 m3 m4 -n1 -n2; K1 K2 K3 K4 -n*u*(i*n1-p1) -n*u*(i*n2-p2); K5 K6 K7 K8 -n*(i*l-(l+2*u)*p1*n1) -n*(i*l-(l+2*u)*p2*n2); K1*e1 K2*e2 K3*e3 K4*e4 0 0; K5*e1 K6*e2 K7*e3 K8*e4 0 0];
D=det(A)

采纳的回答

Walter Roberson
Walter Roberson 2022-8-2
tic
syms c h k
c11=106.8;
c33=54.57;
c13=9.68;
c15=0.28;
c35=-1.69;
c55=25.05;
r1=2727;
l=2.46;
u=5.66;
r2=7800;
i=sqrt(-1);
n=2.54;
a=(c33*c55);
b=(c35^2);
d=(c15*c33);
e=(c13*c35);
f=(c33+c55);
g=(c15*c35);
j=(c11*c33);
m=(c13^2);
o=(c13*c55);
p=(c55+c11);
q=((c11*c55)-c15^2);
r=(c15+c35);
t=(c11*c35-c13*c15);
a0=a-b;
a1=-2*i*(d-e);
a2=f*r1*(c^2)-2*g-j+m+2*o;
a3=-2*i*(r*r1*(c^2)-t);
a4=(r1^2)*(c^4)-p*r1*(c^2)+q;
s=[a0 a1 a2 a3 a4];
root=roots(s);
s1=root(1);
s2=root(2);
s3=root(3);
s4=root(4);
m1=-((c55)*(s1^2)-2*i*(c15)*(s1)+r1*(c^2)-(c11))/((c35)*(s1^2)-i*(c13+c55)*(s1)-(c15));
m2=-((c55)*(s2^2)-2*i*(c15)*(s2)+r1*(c^2)-(c11))/((c35)*(s2^2)-i*(c13+c55)*(s2)-(c15));
m3=-((c55)*(s3^2)-2*i*(c15)*(s3)+r1*(c^2)-(c11))/((c35)*(s3^2)-i*(c13+c55)*(s3)-(c15));
m4=-((c55)*(s4^2)-2*i*(c15)*(s4)+r1*(c^2)-(c11))/((c35)*(s4^2)-i*(c13+c55)*(s4)-(c15));
alpha=sqrt((l+2*u)/r2);
beta=sqrt(u/r2);
b0=(n^2)*((beta^2)/alpha^2);
b1=(n^2)*((1-((beta^2)/(alpha^2))^2))+n*(((c^2)/(alpha^2))-n)+n*((beta^2)/(alpha^2))*((c^2)/(beta^2)-n);
b2=((beta^2)/(alpha^2))*((c^2)/(alpha^2)-n)*((c^2)/(beta^2)-n);
p=[b0 0 b1 0 b2];
proot=roots(p);
p1=proot(1);
p2=proot(2);
p3=proot(3);
p4=proot(4);
n1=(((c^2)/(alpha^2))-n+n*((beta^2)/(alpha^2))*(p1^2))/(i*n*(1-((beta^2)/(alpha^2))*p1));
n2=(((c^2)/(alpha^2))-n+n*((beta^2)/(alpha^2))*(p2^2))/(i*n*(1-((beta^2)/(alpha^2))*p2));
K1=i*(c15)-m1*s1*(c35)+(i*m1-s1)*(c55);
K2=i*(c15)-m2*s2*(c35)+(i*m2-s2)*(c55);
K3=i*(c15)-m3*s3*(c35)+(i*m3-s3)*(c55);
K4=i*(c15)-m4*s4*(c35)+(i*m4-s4)*(c55);
K5=i*(c13)-m1*s1*(c33)+(i*m1-s1)*(c35);
K6=i*(c13)-m2*s2*(c33)+(i*m2-s2)*(c35);
K7=i*(c13)-m3*s3*(c33)+(i*m3-s3)*(c35);
K8=i*(c13)-m4*s4*(c33)+(i*m4-s4)*(c35);
e1=exp(k*s1*h);
e2=exp(k*s2*h);
e3=exp(k*s3*h);
e4=exp(k*s4*h);
A=[1 1 1 1 -1 -1; m1 m2 m3 m4 -n1 -n2; K1 K2 K3 K4 -n*u*(i*n1-p1) -n*u*(i*n2-p2); K5 K6 K7 K8 -n*(i*l-(l+2*u)*p1*n1) -n*(i*l-(l+2*u)*p2*n2); K1*e1 K2*e2 K3*e3 K4*e4 0 0; K5*e1 K6*e2 K7*e3 K8*e4 0 0];
syms AA [6 6]
detA = det(AA);
D = subs(detA, AA, A);
toc
Elapsed time is 18.705740 seconds.
  5 个评论

请先登录,再进行评论。

更多回答(2 个)

neetu malik
neetu malik 2022-8-3
tic
syms c h k
c11=106.8;
c33=54.57;
c13=9.68;
c15=0.28;
c35=-1.69;
c55=25.05;
r1=2727;
l=2.46;
u=5.66;
r2=7800;
i=sqrt(-1);
n=2.54;
a=(c33*c55);
b=(c35^2);
d=(c15*c33);
e=(c13*c35);
f=(c33+c55);
g=(c15*c35);
j=(c11*c33);
m=(c13^2);
o=(c13*c55);
p=(c55+c11);
q=((c11*c55)-c15^2);
r=(c15+c35);
t=(c11*c35-c13*c15);
a0=a-b;
a1=-2*i*(d-e);
a2=f*r1*(c^2)-2*g-j+m+2*o;
a3=-2*i*(r*r1*(c^2)-t);
a4=(r1^2)*(c^4)-p*r1*(c^2)+q;
s=[a0 a1 a2 a3 a4];
root=roots(s);
s1=root(1);
s2=root(2);
s3=root(3);
s4=root(4);
m1=-((c55)*(s1^2)-2*i*(c15)*(s1)+r1*(c^2)-(c11))/((c35)*(s1^2)-i*(c13+c55)*(s1)-(c15));
m2=-((c55)*(s2^2)-2*i*(c15)*(s2)+r1*(c^2)-(c11))/((c35)*(s2^2)-i*(c13+c55)*(s2)-(c15));
m3=-((c55)*(s3^2)-2*i*(c15)*(s3)+r1*(c^2)-(c11))/((c35)*(s3^2)-i*(c13+c55)*(s3)-(c15));
m4=-((c55)*(s4^2)-2*i*(c15)*(s4)+r1*(c^2)-(c11))/((c35)*(s4^2)-i*(c13+c55)*(s4)-(c15));
alpha=sqrt((l+2*u)/r2);
beta=sqrt(u/r2);
b0=(n^2)*((beta^2)/alpha^2);
b1=(n^2)*((1-((beta^2)/(alpha^2))^2))+n*(((c^2)/(alpha^2))-n)+n*((beta^2)/(alpha^2))*((c^2)/(beta^2)-n);
b2=((beta^2)/(alpha^2))*((c^2)/(alpha^2)-n)*((c^2)/(beta^2)-n);
p=[b0 0 b1 0 b2];
proot=roots(p);
p1=proot(1);
p2=proot(2);
p3=proot(3);
p4=proot(4);
n1=(((c^2)/(alpha^2))-n+n*((beta^2)/(alpha^2))*(p1^2))/(i*n*(1-((beta^2)/(alpha^2))*p1));
n2=(((c^2)/(alpha^2))-n+n*((beta^2)/(alpha^2))*(p2^2))/(i*n*(1-((beta^2)/(alpha^2))*p2));
K1=i*(c15)-m1*s1*(c35)+(i*m1-s1)*(c55);
K2=i*(c15)-m2*s2*(c35)+(i*m2-s2)*(c55);
K3=i*(c15)-m3*s3*(c35)+(i*m3-s3)*(c55);
K4=i*(c15)-m4*s4*(c35)+(i*m4-s4)*(c55);
K5=i*(c13)-m1*s1*(c33)+(i*m1-s1)*(c35);
K6=i*(c13)-m2*s2*(c33)+(i*m2-s2)*(c35);
K7=i*(c13)-m3*s3*(c33)+(i*m3-s3)*(c35);
K8=i*(c13)-m4*s4*(c33)+(i*m4-s4)*(c35);
e1=exp(k*s1*h);
e2=exp(k*s2*h);
e3=exp(k*s3*h);
e4=exp(k*s4*h);
A=[1 1 1 1 -1 -1; m1 m2 m3 m4 -n1 -n2; K1 K2 K3 K4 -n*u*(i*n1-p1) -n*u*(i*n2-p2); K5 K6 K7 K8 -n*(i*l-(l+2*u)*p1*n1) -n*(i*l-(l+2*u)*p2*n2); K1*e1 K2*e2 K3*e3 K4*e4 0 0; K5*e1 K6*e2 K7*e3 K8*e4 0 0];
AA =sym('AA',[6 6]);
detA=det(AA);
D=subs(detA, AA, A);
D1=solve(D==0,c)
toc
  2 个评论
Walter Roberson
Walter Roberson 2022-8-3
I am not sure I have that version of MATLAB installed on any accessible drive to test with.
Are you getting any error message?

请先登录,再进行评论。


neetu malik
neetu malik 2022-8-3
Error using plot
Vectors must be the same length.
Error in g3 (line 78)
plot(k,D2,'b')
this error is come
  3 个评论
neetu malik
neetu malik 2022-8-3
tic syms c h k c11=106.8; c33=54.57; c13=9.68; c15=0.28; c35=-1.69; c55=25.05; r1=2727; l=2.46; u=5.66; r2=7800; i=sqrt(-1); n=2.54; a=(c33*c55); b=(c35^2); d=(c15*c33); e=(c13*c35); f=(c33+c55); g=(c15*c35); j=(c11*c33); m=(c13^2); o=(c13*c55); p=(c55+c11); q=((c11*c55)-c15^2); r=(c15+c35); t=(c11*c35-c13*c15); a0=a-b; a1=-2*i*(d-e); a2=f*r1*(c^2)-2*g-j+m+2*o; a3=-2*i*(r*r1*(c^2)-t); a4=(r1^2)*(c^4)-p*r1*(c^2)+q; s=[a0 a1 a2 a3 a4]; root=roots(s); s1=root(1); s2=root(2); s3=root(3); s4=root(4); m1=-((c55)*(s1^2)-2*i*(c15)*(s1)+r1*(c^2)-(c11))/((c35)*(s1^2)-i*(c13+c55)*(s1)-(c15)); m2=-((c55)*(s2^2)-2*i*(c15)*(s2)+r1*(c^2)-(c11))/((c35)*(s2^2)-i*(c13+c55)*(s2)-(c15)); m3=-((c55)*(s3^2)-2*i*(c15)*(s3)+r1*(c^2)-(c11))/((c35)*(s3^2)-i*(c13+c55)*(s3)-(c15)); m4=-((c55)*(s4^2)-2*i*(c15)*(s4)+r1*(c^2)-(c11))/((c35)*(s4^2)-i*(c13+c55)*(s4)-(c15)); alpha=sqrt((l+2*u)/r2); beta=sqrt(u/r2); b0=(n^2)*((beta^2)/alpha^2); b1=(n^2)*((1-((beta^2)/(alpha^2))^2))+n*(((c^2)/(alpha^2))-n)+n*((beta^2)/(alpha^2))*((c^2)/(beta^2)-n); b2=((beta^2)/(alpha^2))*((c^2)/(alpha^2)-n)*((c^2)/(beta^2)-n); p=[b0 0 b1 0 b2]; proot=roots(p); p1=proot(1); p2=proot(2); p3=proot(3); p4=proot(4); n1=(((c^2)/(alpha^2))-n+n*((beta^2)/(alpha^2))*(p1^2))/(i*n*(1-((beta^2)/(alpha^2))*p1)); n2=(((c^2)/(alpha^2))-n+n*((beta^2)/(alpha^2))*(p2^2))/(i*n*(1-((beta^2)/(alpha^2))*p2)); K1=i*(c15)-m1*s1*(c35)+(i*m1-s1)*(c55); K2=i*(c15)-m2*s2*(c35)+(i*m2-s2)*(c55); K3=i*(c15)-m3*s3*(c35)+(i*m3-s3)*(c55); K4=i*(c15)-m4*s4*(c35)+(i*m4-s4)*(c55); K5=i*(c13)-m1*s1*(c33)+(i*m1-s1)*(c35); K6=i*(c13)-m2*s2*(c33)+(i*m2-s2)*(c35); K7=i*(c13)-m3*s3*(c33)+(i*m3-s3)*(c35); K8=i*(c13)-m4*s4*(c33)+(i*m4-s4)*(c35); e1=exp(k*s1*h); e2=exp(k*s2*h); e3=exp(k*s3*h); e4=exp(k*s4*h); A=[1 1 1 1 -1 -1; m1 m2 m3 m4 -n1 -n2; K1 K2 K3 K4 -n*u*(i*n1-p1) -n*u*(i*n2-p2); K5 K6 K7 K8 -n*(i*l-(l+2*u)*p1*n1) -n*(i*l-(l+2*u)*p2*n2); K1*e1 K2*e2 K3*e3 K4*e4 0 0; K5*e1 K6*e2 K7*e3 K8*e4 0 0]; AA =sym('AA',[6 6]); detA=det(AA); D=subs(detA, AA, A); for h=2.4 k=4:0.2:5; D1=solve(D==0,c); D2=real(D1); plot(k,D2,'b') end hold on for h=2.6 k=4:0.2:5; D1=solve(D==0,c); D2=real(D1); plot(k,D2,'r') end hold on for h=2.8 k=4:0.2:5; D1=solve(D==0,c); D2=real(D1); plot(k,D2,'r') end hold off toc
Walter Roberson
Walter Roberson 2022-8-3
If you have the code
A = 1
D = A*5
A = 2
D
Then what value will D be afterwards? Will it be 0 or 1 or 2 or 5 or 10?
If you have the code
syms A
D = A*5
A = 2
D
Then what is the value of D afterwards? Why are you expecting D to have changed in this case when you did not expect D to change in the numeric case?

请先登录,再进行评论。

产品


版本

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by