MATLAB: How to run a 3×3 matrix through a for loop and save all instances of the [3×3]

3d matrixfor loopmatrix manipulation

I have a [3×3] transformation matrix A = [ -sind(omega*t), cosd(omega*t), 0; cosd(omega*t), sind(omega*t) cosd(phi); cosd(omega*t), sind(omega*t), sin(phi)]
omega and phi are constants defined earlier. t is the vaiable that is being looped for. if I have 300 values for t, I would like to output 300 different [3×3] matricies, each one corresponding with a different value of t. for more information t is a value that is being read in from a data sheet.

Best Answer

A is a cell array the same size as t where A{n} is the matrix for t(n).
omega = 1;
phi = 1;
t = linspace(0,5,300);
A = arrayfun(@(t)[-sind(omega*t), cosd(omega*t), 0;
cosd(omega*t), sind(omega*t) cosd(phi);
cosd(omega*t), sind(omega*t), sin(phi)],t,'UniformOutput',false);