MATLAB Answers

Please help me convert them into a function of theta

3 views (last 30 days)
carson yeoh
carson yeoh on 24 Jun 2020
Answered: Bjorn Gustavsson on 24 Jun 2020
Error using ^ (line 51)
Incorrect dimensions for raising a matrix to a power.
Check that the matrix is square and the power is a
scalar. To perform elementwise matrix powers, use '.^'.
I got this when I try to use the equation
Please help me convert them into a function of theta that i can plot as a (theta,x) to test from degree 0 to 360(0 to 2pi).
  2 Comments
carson yeoh
carson yeoh on 24 Jun 2020
abc = (r*(wab^2)*(L^2-r^2).*sin(theta))./((L*L-r*r.*sin(theta).*sin(theta))^(3/2));

Sign in to comment.

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 24 Jun 2020
When you get such an error, your first action would be to look at the sizes of the variables you use:
whos r wab L r theta
Next you'll have think about whether you want matrix-power or elementwise power (same with products - matrix-product or element-wise product). From your equation it seems as if you want elementwise operations, but we cannot know this with absolute certainty. In that case you'll have to modify your expression to something like this:
abc = (r.*(wab.^2)*(L.^2-r.^2).*sin(theta))./((L.*L-r.*r.*sin(theta).*sin(theta)).^(3/2));
HTH

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!