This is the script I am currently processing through MATLAB however it keeps returning me an error that says : ??? Error using ==> mtimes Inner matrix dimensions must agree.
Error in ==> Complexmodel at 12 T1=((elevator_mass+load_mass1)*g+X)*a;
My script:
g=9.81;
elevator_mass=1000;
load_mass1=1500;
load_mass2=2000;
load_mass3=2500;
safe_load=4500;
u=0.6:1:1.6;
a=0:1:10;
safty(1:11)=safe_load;
X=3.*u.^2;
xlabel_information='Elevator acceleration';
T1=((elevator_mass+load_mass1)*g+X)*a;
T2=((elevator_mass+load_mass2)*g+X)*a;
T3=((elevator_mass+load_mass3)*g+X)*a;
plot(a,T1,'b-o',a,T2,'g-o',a,T3,'k-o',a,safty,'.');
xlabel(xlabel_information)
ylabel('Cable Tension')
title('Tension vs Acceleration');
legend('load mass 1','load mass 2','load mass 3','Safe load');
[EDITED, JSimon, 09-Oct-2011 16:19 UTC] Code formatted - please do this by your own, see Markup help

 Akzeptierte Antwort

Jan
Jan am 9 Okt. 2011

0 Stimmen

You could use the debugger to locate the problem:
dbstop if error
Now MATLAB stops, if the error occurs and you can inspect the dimensions:
In: T1=((elevator_mass+load_mass1)*g+X)*a;
((elevator_mass+load_mass1)*g+X => [1 x 2]
a => [1 x 11]
Of course the multiplication is not possible.

4 Kommentare

Nourriee BB
Nourriee BB am 9 Okt. 2011
Im new to matlab so the range of data collected was given to me from a previous class I have done... I have no idea on how I may fix the equation :/
Walter Roberson
Walter Roberson am 9 Okt. 2011
Andrei's version looks plausible, but you will need to decide whether you want .* (element by element multiplication) or if you want bsxfun() (create array with all of the combinations of values), or if you want to transpose one of the vectors and do a matrix multiplication.
Nourriee BB
Nourriee BB am 10 Okt. 2011
if i were to do a matrix multiplication. What would I need to change in my script to make it possible?
Walter Roberson
Walter Roberson am 10 Okt. 2011
if you have two vectors, A and B, each 1 x 11, then you can either do
A * B'
to get a 1 x 1 result,
or you can do
A' * B
to get an 11 x 1 result.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Kategorien

Mehr zu Aerospace Blockset finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by