how can i substitute number with symbol ?

7 ビュー (過去 30 日間)
shahin hashemi
shahin hashemi 2018 年 2 月 16 日
編集済み: shahin hashemi 2018 年 2 月 16 日
dear all
i have code like below :
clc
clear all
N=4;
L=60e-3;
M=3.338e-3;
jx=5.743e-14;
E=2.1e11;
x = sym('x', [1 3*N], 'real');
for j=2:N+1
for i=j-1
f1(j)=(1-cos(x(3*i-2)))/x(3*i-2);
g1(j)=-(1-cos(x(3*i-1)))/x(3*i-1);
f2(j)=sin(x(3*i-2))/x(3*i-2);
g2(j)=sin(x(3*i-1))/x(3*i-1);
pl(:,j)=L*[f1(j) f2(j)*g1(j) f2(j)*g2(j)]';
Rl(:,:,j)=[cos(x(3*i))*cos(x(3*i-2)) -sin(x(3*i))*cos(x(3*i-2)) sin(x(3*i-2));cos(x(3*i))*sin(x(3*i-2))*sin(x(3*i-1))+sin(x(3*i))*cos(x(3*i-1)) -sin(x(3*i))*sin(x(3*i-2))*sin(x(3*i-1))+cos(x(3*i))*cos(x(3*i-1)) -cos(x(3*i-2))*sin(x(3*i-1));-cos(x(3*i))*sin(x(3*i-2))*cos(x(3*i-1))+sin(x(3*i))*sin(x(3*i-1)) sin(x(3*i))*sin(x(3*i-2))*cos(x(3*i-1))+cos(x(3*i))*sin(x(3*i-1)) cos(x(3*i-2))*cos(x(3*i-1))];
p(:,2)=pl(:,2);
end
end
R(:,:,2)=Rl(:,:,2);
R(:,:,1)=[1 0 0;0 1 0;0 0 1];
for i=3:N+1
R(:,:,i)=R(:,:,i-1)*Rl(:,:,i);
p(:,i)=p(:,i-1)+R(:,:,i-1)*pl(:,i);
end
for j=2:N+1
for i=1:N
for r=1:N
d1Pbeta(:,j,i)=diff(p(:,j),x(3*i-2));
d2Pbetabeta(:,j,i,r)=dot([-M*9.81 0 0],diff(d1Pbeta(:,j,i),x(3*r-2)));
end
end
end
for i=1:N
for r=1:N
for j=2:N+1
sigm(i,r)=(E*jx/L)+sum(d2Pbetabeta(:,j,i,r)');
end
end
end
here i want to replace x with number
x=[0.0495837022782378;3.96268247549320e-09;-4.78044641555791e-10;0.0854433755724521;2.89430795211353e-09;-1.43061297211777e-10;0.110831068380515;4.80530147316531e-09;-5.69420213726607e-10;0.125761304817654;1.09464269988965e-08;-4.73181277688372e-10]
but it doesnt work
and after that calculate eigenvalue of sigm
e=eig(sigm)

採用された回答

Birdman
Birdman 2018 年 2 月 16 日
  1 件のコメント
shahin hashemi
shahin hashemi 2018 年 2 月 16 日
編集済み: shahin hashemi 2018 年 2 月 16 日
thank you for your attention bird man but when i use this command like below :
subs(sigm,(x(11)),0.1)
it replace x(11) with 0.1 and answer cos(0.1) and doesn't calculate it i mean cos(0.1)=0.9 i think it is still in symbol mod
any solutions ?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Mobile Fundamentals についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by