Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

TimerFcn, Error using VertCat?

2 visualizaciones (últimos 30 días)
Mohsin
Mohsin el 27 de Jun. de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
This is my code:
set(t,'ExecutionMode','fixedrate','Period',1,'TimerFcn',[
'cent=(y3dnew(1,:)+y3dnew(5,:))/2;' ,
'xax=(y3dnew(4,:)+y3dnew(5,:))/2 - cent;',
'yax=y3dnew(3,:) - cent;',
'yax=yax/norm(yax);',
'axi=xax/norm(xax);',
'normal=cross(axi,yax);',
'phi=.5;',
'M = [cosd(phi)+axi(1)^2*(1-cosd(phi)) axi(1)*axi(2)*(1-cosd(phi))+axi(3)*sind(phi) axi(1)*axi(3)*(1-cosd(phi))-axi(2)*sind(phi) ; axi(1)*axi(2)*(1-cosd(phi))-axi(3)*sind(phi) cosd(phi)+axi(2)^2*(1-cosd(phi)) axi(2)*axi(3)*(1-cosd(phi))+axi(1)*sind(phi); axi(1)*axi(3)*(1-cosd(phi))+axi(2)*sind(phi) axi(2)*axi(3)*(1-cosd(phi))-axi(1)*sind(phi) cosd(phi)+axi(3)^2*(1-cosd(phi)) ];',
'y3dnew(1,:)=(y3dnew(1,:)-cent)*M+cent;',
'y3dnew(2,:)=(y3dnew(2,:)-cent)*M+cent;',
'y3dnew(3,:)=(y3dnew(3,:)-cent)*M+cent;',
'y3dnew(4,:)=(y3dnew(4,:)-cent)*M+cent;',
'y3dnew(5,:)=(y3dnew(5,:)-cent)*M+cent;',
'trans=[0 -2*norm(cent)*sind(phi) 0]*inv([normal(1) axi(1) yax(1); normal(2) axi(2) yax(2);normal(3) axi(3) yax(3)]);',
'y3dnew(1,:)=y3dnew(1,:)-trans;',
'y3dnew(2,:)=y3dnew(2,:)-trans;',
'y3dnew(3,:)=y3dnew(3,:)-trans;',
'y3dnew(4,:)=y3dnew(4,:)-trans;',
'y3dnew(5,:)=y3dnew(5,:)-trans;',
'cent=(y3dnew(1,:)+y3dnew(5,:))/2;',
'y3dnew(1,:)=(y3dnew(1,:)-cent)*M+cent;',
'y3dnew(2,:)=(y3dnew(2,:)-cent)*M+cent;',
'y3dnew(3,:)=(y3dnew(3,:)-cent)*M+cent;',
'y3dnew(4,:)=(y3dnew(4,:)-cent)*M+cent;',
'y3dnew(5,:)=(y3dnew(5,:)-cent)*M+cent;'],'TasksToExecute',500);
Now I'm getting an error:
Error using ==> vertcat
CAT arguments dimensions are not consistent
Now when I run each line in the TimerFcn separately, there seems to be no error. So, it must be something to do with TimerFcn syntax?
btw, y3dnew is a 5x3 matrix of numbers. And the M in the code is a 3x3 matrix of numbers.
Sorry for the inelegance of the code, but I need help

Respuestas (1)

TAB
TAB el 27 de Jun. de 2012
Instead of providing such large code in the set() function argument , I will recommend you to write the code as separate callback function in different m-file and provide the file name as argument to set() function.
See here about how to write a timer callback function.
  5 comentarios
Jan
Jan el 8 de Jul. de 2012
Editada: Jan el 9 de Jul. de 2012
@TAB: I've removed your flag. I agree with you, that your suggestion is much better than Mohsin's solution. But obviously he has good reasons and forgot to explain them. But you get my vote.
TAB
TAB el 9 de Jul. de 2012
OK, Jan.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by