Error using interpreted matlab function block in Simulink
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Since type "syms" is not supported in Matlab Function Block, so I have to use the interpreted Matlab Function Block, However, error occured on this Block when running Simulink. Is there any way to solve this? Thank you so much!!!
Below is the function I called in the interpreted Matlab Function Block.
function result= Solve(qt)
%r contains coordinates of every joint
r=zeros(27,1);
l=60;
%Joint 1-3
r(1)=sqrt(3)*l/4;
r(4)=-sqrt(3)*l/4;
r(5)=l/2;
r(7)=r(4);
r(8)=-l/2;
%Joint4
r(10)=sqrt(3)*l/4;
r(11)=-l/2;
r(12)=sqrt(3)*l/2;
%Joint5
r(13)=sqrt(3)*l/4;
r(14)=l/2;
r(15)=sqrt(3)*l/2;
%Joint6
r(16)=-sqrt(3)*l/4;
r(17)=0;
r(18)=sqrt(3)*l/2;
%Joint7
r(19)=r(1);
r(20)=r(2);
r(21)=sqrt(3)*l;
%Joint8
r(22)=r(4);
r(23)=r(5);
r(24)=sqrt(3)*l;
%Joint9
r(25)=r(7);
r(26)=r(8);
r(27)=sqrt(3)*l;
guess=r;
A = sym('A', [3 9]);
Coor=sym('B',[27,1]);
%Lower Octahedral
Coor(1)=transpose(A(:,4)-A(:,3))*(A(:,4)-A(:,3))-l^2;
Coor(2)=transpose(A(:,4)-A(:,1))*(A(:,4)-A(:,1))-l^2;
Coor(3)=transpose(A(:,4)-A(:,5))*(A(:,4)-A(:,5))-qt(1)^2;
Coor(4)=transpose(A(:,5)-A(:,1))*(A(:,5)-A(:,1))-l^2;
Coor(5)=transpose(A(:,5)-A(:,2))*(A(:,5)-A(:,2))-l^2;
Coor(6)=transpose(A(:,5)-A(:,6))*(A(:,5)-A(:,6))-qt(2)^2;
Coor(7)=transpose(A(:,6)-A(:,3))*(A(:,6)-A(:,3))-l^2;
Coor(8)=transpose(A(:,6)-A(:,2))*(A(:,6)-A(:,2))-l^2;
Coor(9)=transpose(A(:,6)-A(:,4))*(A(:,6)-A(:,4))-qt(3)^2;
%Upper Octahedral
Coor(10)=transpose(A(:,7)-A(:,4))*(A(:,7)-A(:,4))-l^2;
Coor(11)=transpose(A(:,7)-A(:,5))*(A(:,7)-A(:,5))-l^2;
Coor(12)=transpose(A(:,7)-A(:,8))*(A(:,7)-A(:,8))-qt(4)^2;
Coor(13)=transpose(A(:,8)-A(:,5))*(A(:,8)-A(:,5))-l^2;
Coor(14)=transpose(A(:,8)-A(:,6))*(A(:,8)-A(:,6))-l^2;
Coor(15)=transpose(A(:,8)-A(:,9))*(A(:,8)-A(:,9))-qt(5)^2;
Coor(16)=transpose(A(:,9)-A(:,6))*(A(:,9)-A(:,6))-l^2;
Coor(17)=transpose(A(:,9)-A(:,4))*(A(:,9)-A(:,4))-l^2;
Coor(18)=transpose(A(:,9)-A(:,7))*(A(:,9)-A(:,7))-qt(6)^2;
%r1 r2 & r3 are known
Coor(19)=A(1,1)-sqrt(3)*l/4;
Coor(20)=A(2,1);
Coor(21)=A(3,1);
Coor(22)=A(1,2)+A(1,1);
Coor(23)=A(2,2)-l/2;
Coor(24)=A(3,2);
Coor(25)=A(1,3)-A(1,2);
Coor(26)=A(2,3)+l/2;
Coor(27)=A(3,2);
%Use fsolve to solve the system based on current value of q
[result, fval, exit, output]=fsolve(Coor,guess);
% result
% fval
% eqns(guess)
% output
end
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre General Applications en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!