Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab Function - Error using => horzcat

  1. Nov 16, 2011 #1
    Code (Text):
    function out = rotatex(angle, in)
    m=[1 0 0 0; 0 cos(angle) -sin(angle) 0; 0 sin(angle) cos(angle) 0; 0 0 0 1];
    out = m*in;
    And the call:

    Code (Text):

    >> out = rotatex(in, pi/4);
    ??? Error using ==> horzcat
    CAT arguments dimensions are not consistent.

    Error in ==> rotatex at 2
    m=[1 0 0 0; 0 cos(angle) -sin(angle) 0; 0 sin(angle) cos(angle) 0; 0 0 0 1];
    I've counted the elements, tested the declaration outside the function, and it works. I've removed the minus before the sin. I've declared the rows seperately and tried calling horzcat explicitly and as soon as the trig functions are included it throws a hissyfit..but only when it is called from within the function.

    Help much appreciated. In the meantime I'll just head off on a murderous rampage...wanders off muttering expletives.
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Matlab Function - Error using => horzcat
Loading...