Error using ==> plus,Matrix dimensions must agree

U4=asin(distance(v1,v2,v9,v10).*sin(angle1(v1,v2,v7,v8,v9,v10,0)+deltaMINt(v1,v2,v3,v4,v5,v6))./FJt(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10))+acos((FJt(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10).^2+distance(v7,v8,v11,v12)^2-(distance(v9,v10,v11,v12)+S4(i)).^2)./(2*FJt(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10)*distance(v7,v8,v11,v12)))-angle1(v7,v8,v1,v2,v11,v12,0)+angle1(v7,v8,v13,v14,v15,v16,0);%+GFD(v11,v12,v9,v10,v7,v8,v13,v14,v15,v16);
end
Above is an function created by me to calculate an angle, distance(v1,v2,v9,v10). and angle1(v1,v2,v7,v8,v9,v10,0) is an fixed angle, deltaMINt(v1,v2,v3,v4,v5,v6) and FJt(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10) are two angle depend on an function which is depedent on time, and tehe time is seperated into 86 points between 0 and 8.5 second. I call the above function in the command window in condition that I supply these variables value,the function can calculate and obtain a series of results(1X86 arrays),but when I call the below M-file in the command window,It always shot such error as :Error using ==> plus,Matrix dimensions must agree.how solve the problem?Thank you very mu for teling me the method to solve.
x1=0;x2=207;x3=-40.2;x4=66.6;x5=51.9;x6=151.5;x7=101.8;x7=132.8;x9=21.7;x10=180.8;x11=92.1;x12=84.8;x13=119;x14=177.6;x15=156.9;x16=61.4;x17=173.3;x18=103.3;
x19=189.7;x20=145.2;x21=218.6;x22=32;x23=257.8;x24=115.2;
global x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24
Objfun=objfun(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,x21,x22,x23,x24);

1 Commento

You missed out at least one line from the function.
distance(v1,v2,v9,v10). and angle1(v1,v2,v7,v8,v9,v10,0) is an fixed angle
Are you saying that distance and angle1 are arrays that are being indexed by the various variables? That would not work because you have a 0 at the end of the list for angle1 and 0 is not a valid index.
If they are functions we must know what size they return.
deltaMINt(v1,v2,v3,v4,v5,v6) and FJt(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10) are two angle depend on an function which is depedent on time, and tehe time is seperated into 86 points between 0 and 8.5 second.
I do not see any time in what you posted? Is the 0 to 8.5 being generated inside those functions?
The various x values look like angles in degrees to me, but I notice that you use sin and asin which expect radians. Are you doing a conversion to radians somewhere?
Anyhow, break up your expression into terms, and find the size() of each term.
I suspect that you are using MATLAB R2016a or earlier and that one of your functions returns a row vector but the other returns a column vector.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su General Applications in Centro assistenza e File Exchange

Richiesto:

il 10 Mar 2020

Commentato:

il 10 Mar 2020

Community Treasure Hunt

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

Start Hunting!

Translated by