필터 지우기
필터 지우기

error Inner matrix dimensions must agree?

조회 수: 1 (최근 30일)
safisay
safisay 2017년 11월 15일
댓글: safisay 2017년 11월 15일
Hi,
Can anyone tell me what's wrong with the code?
if true
k_1=0.423;
F=1.06;
gama=pi/F;
thetac=0:0.1:gama;
theta1=thetac;
theta0=0.4561;
l=0.21818;
j_L_theta1=(theta1*l)/2;
M=(k_1*(sin(theta0 - theta1)*sin(k_1*theta0)*sin(k_1*(gama - theta1)) - k_1*sin(k_1*(gama - theta1)) - sin(theta0 - theta1)*cos(k_1*theta0) + k_1*cos(theta0 - theta1)*sin(k_1*theta0) - sin(theta0 - theta1)*cos(k_1*theta0)*cos(k_1*(gama - theta1)) + k_1*cos(theta0 - theta1)*cos(k_1*theta0)*sin(k_1*(gama - theta1)) + k_1*cos(theta0 - theta1)*sin(k_1*theta0)*cos(k_1*(gama - theta1))))/(2*j_L_theta1*k_1 - k_1*sin(theta0 - theta1) - k_1^2*cos(k_1*theta0)*sin(k_1*(gama - theta1)) - k_1^2*sin(k_1*theta0)*cos(k_1*(gama - theta1)) - k_1*sin(theta0 - theta1)*cos(k_1*theta0)*cos(k_1*(gama - theta1)) + j_L_theta1*sin(theta0 - theta1)*cos(k_1*theta0)*sin(k_1*(gama - theta1)) + j_L_theta1*sin(theta0 - theta1)*sin(k_1*theta0)*cos(k_1*(gama - theta1)) + k_1*sin(theta0 - theta1)*sin(k_1*theta0)*sin(k_1*(gama - theta1)) + k_1^2*cos(theta0 - theta1)*cos(k_1*theta0)*sin(k_1*(gama - theta1)) + k_1^2*cos(theta0 - theta1)*sin(k_1*theta0)*cos(k_1*(gama - theta1)) + j_L_theta1*k_1^2*sin(theta0 - theta1)*cos(k_1*theta0)*sin(k_1*(gama - theta1)) + j_L_theta1*k_1^2*sin(theta0 - theta1)*sin(k_1*theta0)*cos(k_1*(gama - theta1)) + 2*j_L_theta1*k_1*cos(theta0 - theta1)*cos(k_1*theta0)*cos(k_1*(gama - theta1)) - 2*j_L_theta1*k_1*cos(theta0 - theta1)*sin(k_1*theta0)*sin(k_1*(gama - theta1)))
plot(thetac,M)
end

채택된 답변

David Goodmanson
David Goodmanson 2017년 11월 15일
Hi safisay, presumably you want to multiply all the vectors together element-by-element so in the expression for M you have to replace every
* by .*
(I did that in one go with the ctrl-f replace option in the editor). Then also replace the
/ by ./
and you get an answer. If you drop the thetac spacing from .1 to .01 you will see an issue with M.
Your expression for M is so long that I don't know how you would ever check its veracity, or how someone else looking at it would have an idea what it does. You might want to consider breaking it up into pieces. or at least using the ... line break command at strategic spots to get it into a block that's no wider than the page.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Write Unit Tests에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by