why the program is not running .

10 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 3 Ago 2022
k=4:0.2:5;
D1=solve(D==0,c);
Consider the following code:
A = 1
B = 10*A
A = 2
What is the value of B after those three lines of code? Is B a formula that automatically updates as the original variables change? (If it is then B=B+1 leads to some interesting consequences)
When you syms k and assign an expression in k to a variable, and then assign a number to k, then does the variable get updated to reflect the new value of k? If so you can get into some contradictions easily.
You should read the documentation for subs()
  27 Commenti
neetu malik
neetu malik il 6 Ago 2022
i want to graph between k and c for h=2.4, 2.6 and 2.8
Walter Roberson
Walter Roberson il 6 Ago 2022
Yes. That surf() command at the bottom plots with H on the x axis, and k on the y axis, and c on the z axes.
Note that that particular surf() call only displays the real component of the c values. Since the values are complex, you will want to change how you choose to do the plotting.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by