0

I want to create in Simulink, a homogenous matrix in order to simulate the rotation and translation of an object in space.

How can I create a 4x4 matrix which will take as input the angle given?

For example a translation across the X axes combined with a rotation in Z would be in MATLAB:

%Supposing the input is 
in = [a, b]
%translational part:
transl = eye(4);
transl (1,4) = in(1);

%Rotational Part:
rotat = eye(4);
rotat(1:3,1:3) = rotx(in(2));

move = transl*rotat;

The main problem is that I would like the Simulink model to be the more code-free (without MATLAB interpreted functions etc), just blocks.

Thank you.

Spyros
  • 289
  • 1
  • 6
  • 20
  • What is rotx? If it's a MATLAB function then you are either going to have to use interpreted functionality or translate it into pure Simulink too. – Phil Goddard Aug 05 '13 at 14:19
  • This is the MATLAB function that I want to "translate" into Simulink. It rotates around axes X. And exactly that is my question, How can I use blocks (which blocks) so it is pure Simulink and not interpreted functions. – Spyros Aug 05 '13 at 15:31
  • Just use a MATLAB Function block. It is not interpreted, rather it gets converted to C and compiled during model initialization. So there's no speed hit, it can be used with Simulink Coder, and doing this in "pure" Simulink is just messy. – Phil Goddard Aug 06 '13 at 16:38

2 Answers2

1

First off, sometimes code is the better way to accomplish something. Some things are needlessly complicated when done as signal processing.

A Vector Concatenate can be used to generate a vector, which in turn can be fed into a Matrix Concatenate to create a matrix. Both blocks are found under Math Operations. There you should also find all methods necessary to multiply it with the given values, etc.

Daniel R.
  • 66
  • 5
1

Try the 'Rotation Angles to Direction Cosine Matrix' block. It converts rotation angles to direction cosine matrix. The output is a 3x3 matrix, Rxyz, that performs coordinate transformations based on rotation angles from body frame to earth frame.

UserK
  • 884
  • 3
  • 17
  • 40