MATLAB: How to calculate Matrix within loops? store values for n numbers fo 3*3 and 6*6 matrix

compositesfor loopMATLAB Builder EXMATLAB C/C++ Math LibraryMATLAB Production Servermatrixmatrix manipulation

T(i)=[m(i)*m(i) n(i)*n(i) 2*m(i)*n(i); n(i)*n(i) m(i)*m(i) -2*m(i)*n(i); -m(i)*n(i) m(i)*n(i) (m(i)*m(i))-(n(i)*n)];
I have to calculate T for n1(n Nos.)

Best Answer

  • Replace the assignment with
    T(:,:,i) = [m(i)*m(i) n(i)*n(i) 2*m(i)*n(i); n(i)*n(i) m(i)*m(i) -2*m(i)*n(i); -m(i)*n(i) m(i)*n(i) (m(i)*m(i))-(n(i)*n)];
    The only thing that changed is the place being assigned to.