필터 지우기
필터 지우기

Please help me convert them into a function of theta

조회 수: 1 (최근 30일)
carson yeoh
carson yeoh 2020년 6월 24일
답변: Bjorn Gustavsson 2020년 6월 24일
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
KSSV
KSSV 2020년 6월 24일
The error is clear....if you have a matrix, A if you want to find the power each element of A, use element by element power
A2 = A.^2
You attach the code, you tried..so you can get help.
carson yeoh
carson yeoh 2020년 6월 24일
abc = (r*(wab^2)*(L^2-r^2).*sin(theta))./((L*L-r*r.*sin(theta).*sin(theta))^(3/2));

댓글을 달려면 로그인하십시오.

답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2020년 6월 24일
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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by