Clear Filters
Clear Filters

error Inner matrix dimensions must agree?

1 view (last 30 days)
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

Accepted Answer

David Goodmanson
David Goodmanson on 15 Nov 2017
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.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!