Matlab Function - Error using => horzcat

  • MATLAB
  • Thread starter mycroft
  • Start date
  • #1
8
0
Code:
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:
>> 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.
 

Answers and Replies

  • #2
Wrichik Basu
Insights Author
Gold Member
2020 Award
1,661
1,534
The problem exists in the fact that you've not used the horzcat function anywhere in the codes you've shown. What is in in the function call? I tried the code using angles in the function call and got no problem. The problem should exist in the code you've not shown us.
 

Related Threads on Matlab Function - Error using => horzcat

Replies
1
Views
2K
  • Last Post
Replies
2
Views
841
  • Last Post
Replies
2
Views
6K
  • Last Post
Replies
6
Views
2K
Replies
1
Views
7K
  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
1
Views
2K
Replies
2
Views
6K
  • Last Post
Replies
4
Views
8K
Replies
4
Views
2K
Top