how can i substitute number with symbol ?
    7 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    shahin hashemi
 el 16 de Feb. de 2018
  
    
    
    
    
    Editada: shahin hashemi
 el 16 de Feb. de 2018
            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)
0 comentarios
Respuesta aceptada
  Birdman
      
      
 el 16 de Feb. de 2018
        Use subs command.
1 comentario
  shahin hashemi
 el 16 de Feb. de 2018
				
      Editada: shahin hashemi
 el 16 de Feb. de 2018
  
			
		Más respuestas (0)
Ver también
Categorías
				Más información sobre MATLAB Mobile Fundamentals en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

