Input a certain value into a symbolic matrix

In advance, sorry for my English. The problem is that my M matrix is a symbolic matrix containing variable 'w' I simple want to input a certain number in the M matrix instead of the variable 'w' Here's my clumsy MATLAB code. I hope somebody can help me.
%========================================================================
L=1; K1=100000; Kt1=50000; K2=2000; Kt2=1000; E=0.26e10; q=7800;
b=0.05; h=0.01;
area=b*h; I=b*h^3/12;
a=(q*area*w^2/(E*I))^(1/4);
Q(x)=A*sin(a*x)+B*cos(a*x)+C*sinh(a*x)+D*cosh(a*x); %Q(x)
d1Q(x)=diff(Q(x)); %Q(x)'
d2Q(x)=diff(d1Q(x)); %Q(x)''
d3Q(x)=diff(d2Q(x)); %Q(x)'''
d4Q(x)=diff(d3Q(x)); %Q(x)''''
Q_0=Q(0); d1Q_0=d1Q(0); d2Q_0=d2Q(0); d3Q_0=d3Q(0); d4Q_0=d4Q(0);
Q_L=Q(L); d1Q_L=d1Q(L); d2Q_L=d2Q(L); d3Q_L=d3Q(L); d4Q_L=d4Q(L);
BC1=d3Q_0-Q_0*K1/(E*I);
BC2=Kt1*d1Q_0/(E*I)-d2Q_0 ;
BC3=K2*Q_L/(E*I)-d3Q_L ;
BC4=d2Q_L+Kt2*d1Q_L/(E*I) ;
M1=equationsToMatrix(BC1==0,[A,B,C,D]) ;
M2=equationsToMatrix(BC2==0,[A,B,C,D]) ;
M3=equationsToMatrix(BC3==0,[A,B,C,D]) ;
M4=equationsToMatrix(BC4==0,[A,B,C,D]) ;
M=[M1;M2;M3;M4]; % This is the M matrix containing variable 'w'
i=1;j=1;
for w=0:0.05:3000 % I set the value w, but it does not go into the M matrix.
y(i)=w;
dm(i)=det(M);
if ((i>=2) && ((dm(i-1)*dm(i))<0))
f(j)=(y(i-1)+y(i))/2;
j=j+1
end % decide whether the w value makes the M determinant passing 0, if yes, this is the nature frequency
i=i+1;
end

回答(1 个)

newM = subs(M, w, numeric_value_for_w);
newM would then be a symbolic matrix, but with all occurrences of w replaced by the numeric value.

2 个评论

I already figured out using 'subs' but... If I use exact value for w it looks like this. let the value 0.05
M=sub(M,w,0.05)
but, if I need to increase 'w' I need to use 'for' or other iterations. Then, it looks like this
for m:1:1000
M=subs(M,w,w)
end
In that case, the value of w does not get into Matrix M.
You need to keep the symbolic M to subs into and create newM in each iteration and work with that.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by