How can I resolve this error

This error keeps coming up for the line of codes below
Error using * Inner matrix dimensions must agree.
A=2;
S=1;
Nt=0.2;
Nb=0.2;
B=0.01; % Beta
Y=0.1; %Gamma
Le=1;
Pr=1.0;
M1=0;
C=-1;
n=1:0.1:2;
%F0 =A + n/2 - (A*n) - (n*((2*A) - 1)*((2*n.^2) - ((3*n) + 1)))/(2*((6*B) - 1));
%F1 =(n*(n - 1)*((83*S) - (60*C) - (60*C*n) + (83*S*n) + (152*A^2*S) + (60*C*n.^2) - (87*S*n.^2) + (3*S*n.^3) - (242*A*S) - (168*A^2*S*n.^2) + (12*A^2*S*n.^3) - (242*A*S*n) + (258*A*S*n.^2) + (152*A^2*S*n) - (12*A*S*n.^3)))/1440 - (n*(n - 1)*(- 1188*S*A^2 - 1416*S*A + 560*C + 1005*S))/(13440*(2*B - 1)) - (n*(n - 1)*(2*A - 1)*(473*S - 946*S*n - 336*M1^2*n - 106*S*n.^2 + 314*S*n.^3 - 736*S*n.^4 + 734*S*n.^5 - 286*S*n.^6 + 20*S*n.^7 + 168*M1^2 + 62*A*S - 124*A*S*n + 212*A*S*n.^2 - 628*A*S*n.^3 + 1472*A*S*n.^4 - 1468*A*S*n.^5 + 572*A*S*n.^6 - 40*A*S*n.^7))/(20160*(6*B - 1)^2) - (n*(n - 1)*(2*A - 1)*(2095*S - 3244*S*n + 112*M1^2*n + 116*S*n.^2 + 2916*S*n.^3 - 500*S*n.^4 + 32*S*n.^5 + 112*M1^2 - 1008*M1^2*n.^2 + 672*M1^2*n.^3 - 74*A*S + 272*A*S*n + 272*A*S*n.^2 - 1128*A*S*n.^3 + 664*A*S*n.^4 - 64*A*S*n.^5))/(13440*(6*B - 1));
%F2 =(n*(n - 1)*(3480*A^3*S^2*n.^6 - 120*A^3*S^2*n.^7 - 25800*A^3*S^2*n.^5 + 41400*A^3*S^2*n.^4 + 54168*A^3*S^2*n.^3 - 105432*A^3*S^2*n.^2 + 8008*A^3*S^2*n + 8008*A^3*S^2 + 1440*A^2*M1^2*S*n.^5 - 28800*A^2*M1^2*S*n.^4 + 51840*A^2*M1^2*S*n.^3 + 51840*A^2*M1^2*S*n.^2 - 75840*A^2*M1^2*S*n - 75840*A^2*M1^2*S + 180*A^2*S^2*n.^7 - 6840*A^2*S^2*n.^6 + 63000*A^2*S^2*n.^5 - 176400*A.^2*S.^2*n.^4 - 142632*A.^2*S.^2*n.^3 + 642348*A.^2*S.^2*n.^2 - 268692*A.^2*S.^2*n - 268692*A.^2*S.^2 - 1440*A*M1.^2*S*n.^5 + 43920*A*M1.^2*S*n.^4 - 82080*A*M1.^2*S*n.^3 - 82080*A*M1.^2*S*n.^2 + 121200*A*M1.^2*S*n + 121200*A*M1.^2*S - 90*A*S.^2*n.^7 + 4230*A*S.^2*n.^6 - 46890*A*S.^2*n.^5 + 198810*A*S.^2*n.^4 + 110106*A*S.^2*n.^3 - 810324*A*S.^2*n.^2 + 416316*A*S.^2*n + 416316*A*S.^2 - 900*C*A*S*n.^6 + 9180*C*A*S*n.^5 - 16020*C*A*S*n.^4 - 21060*C*A*S*n.^3 + 41940*C*A*S*n.^2 - 3420*C*A*S*n - 3420*C*A*S + 360*M1.^2*S*n.^5 - 14760*M1.^2*S*n.^4 + 28080*M1.^2*S*n.^3 + 28080*M1.^2*S*n.^2 - 41640*M1.^2*S*n - 41640*M1.^2*S + 10080*C*M1.^2*n.^4 - 20160*C*M1.^2*n.^3 - 20160*C*M1.^2*n.^2 + 30240*C*M1.^2*n + 30240*C*M1.^2 + 15*S.^2*n.^7 - 840*S.^2*n.^6 + 10920*S.^2*n.^5 - 60480*S.^2*n.^4 - 26166*S.^2*n.^3 + 257754*S.^2*n.^2 - 141986*S.^2*n - 141986*S.^2 + 450*C*S*n.^6 - 6750*C*S*n.^5 + 43650*C*S*n.^4 + 15930*C*S*n.^3 - 185670*C*S*n.^2 + 104130*C*S*n + 104130*C*S))/7257600 + (n*(n - 1)*(89561472*A.^3*S.^2*n.^8 - 3075072*A.^3*S.^2*n.^9 - 787474688*A.^3*S^.2*n.^7 + 2060295952*A.^3*S.^2*n.^6 - 2260866608*A.^3*S.^2*n.^5 + 1021676656*A.^3*S.^2*n.^4 - 166550384*A.^3*S.^2*n.^3 + 90506416*A.^3*S.^2*n.^2 + 5276128*A.^3*S.^2*n - 27910952*A.^3*S.^2 + 38438400*A.^2*M1.^2*S*n.^7 - 445885440*A.^2*M1.^2*S*n.^6 + 1076275200*A.^2*M1.^2*S*n.^5 - 538137600*A.^2*M1.^2*S*n.^4 - 570425856*A^2*M1^2*S*n.^3 + 331915584*A^2*M1^2*S*n.^2 + 118582464*A^2*M1^2*S*n - 69381312*A^2*M1^2*S + 4612608*A^2*S^2*n.^9 - 160864704*A^2*S^2*n.^8 + 1685139456*A^2*S^2*n.^7 - 5005973544*A^2*S^2*n.^6 + 1301067768*A^2*S^2*n.^5 + 10352013672*A^2*S^2*n.^4 - 12043783752*A^2*S^2*n.^3 + 3404128728*A^2*S^2*n.^2 + 2385164496*A^2*S^2*n - 1175744148*A^2*S^2 - 276756480*A*M1^4*n.^5 + 691891200*A*M1^4*n.^4 - 276756480*A*M1^4*n.^3 - 276756480*A*M1^4*n.^2 + 46126080*A*M1^4*n + 46126080*A*M1^4 - 38438400*A*M1^2*S*n.^7 + 549669120*A*M1^2*S*n.^6 - 3048165120*A*M1^2*S*n.^5 + 987866880*A*M1^2*S*n.^4 + 6832041216*A*M1^2*S*n.^3 - 6481098624*A*M1^2*S*n.^2 + 633849216*A*M1^2*S*n + 852948096*A*M1^2*S - 2306304*A*S^2*n.^9 + 93693600*A*S^2*n.^8 - 1103182080*A*S^2*n.^7 + 3802372860*A*S^2*n.^6 - 2221631412*A*S^2*n.^5 - 18093399324*A*S^2*n.^4 + 23410198812*A*S^2*n.^3 - 2265090828*A*S^2*n.^2 - 3344796312*A*S^2*n + 1599920202*A*S^2 - 13453440*C*A*S*n.^8 + 207567360*C*A*S*n.^7 - 628467840*C*A*S*n.^6 + 882161280*C*A*S*n.^5 - 691891200*C*A*S*n.^4 + 317116800*C*A*S*n.^3 - 86486400*C*A*S*n.^2 - 31711680*C*A*S*n + 21621600*C*A*S + 138378240*M1^4*n.^5 - 345945600*M1^4*n.^4 + 138378240*M1^4*n.^3 + 138378240*M1^4*n.^2 - 23063040*M1^4*n - 23063040*M1^4 + 9609600*M1^2*S*n.^7 - 163363200*M1^2*S*n.^6 + 1255013760*M1^2*S*n.^5 - 359399040*M1^2*S*n.^4 - 3273414144*M1^2*S*n.^3 + 3157570416*M1^2*S*n.^2 - 346570224*M1^2*S*n - 409128720*M1^2*S + 384384*S^2*n.^9 - 17825808*S^2*n.^8 + 228740512*S^2*n.^7 - 907230038*S^2*n.^6 + 1068157090*S^2*n.^5 + 6330986662*S^2*n.^4 - 8673334670*S^2*n.^3 + 270199930*S^2*n.^2 + 1075447516*S^2*n - 502535195*S^2 + 6726720*C*S*n.^8 - 103783680*C*S*n.^7 + 314233920*C*S*n.^6 - 441080640*C*S*n.^5 + 345945600*C*S*n.^4 - 158558400*C*S*n.^3 + 43243200*C*S*n.^2 - 298378080*C*S*n + 146306160*C*S))/(116237721600*(6*B - 1)) + (n*(n - 1)*(128432304*A^3*S^2*n.^5 - 10193040*A^3*S^2*n.^6 - 299675376*A^3*S^2*n.^4 + 527999472*A^3*S^2*n.^3 - 470918448*A^3*S^2*n.^2 - 12231648*A^3*S^2*n + 34207848*A^3*S^2 + 285405120*A^2*M1^2*S*n.^2 - 285405120*A^2*M1^2*S*n - 669404736*A^2*M1^2*S - 7052760*A^2*S^2*n.^6 + 88864776*A^2*S^2*n.^5 - 207351144*A^2*S^2*n.^4 + 279711432*A^2*S^2*n.^3 + 658810152*A^2*S^2*n.^2 - 864678672*A^2*S^2*n - 1903479180*A^2*S^2 + 340179840*A*M1^2*S*n.^2 - 340179840*A*M1^2*S*n + 282522240*A*M1^2*S + 14697540*A*S^2*n.^6 - 185189004*A*S^2*n.^5 + 432107676*A*S^2*n.^4 - 863386524*A*S^2*n.^3 + 1852646796*A*S^2*n.^2 - 1002902472*A*S^2*n + 670256934*A*S^2 + 4804800*C*A*S*n.^6 - 60540480*C*A*S*n.^5 + 141261120*C*A*S*n.^4 - 248888640*C*A*S*n.^3 + 221981760*C*A*S*n.^2 + 5765760*C*A*S*n - 18418400*C*A*S - 241441200*M1^2*S*n.^2 + 241441200*M1^2*S*n + 26090064*M1^2*S - 134534400*C*M1^2*n.^2 + 134534400*C*M1^2*n + 295975680*C*M1^2 - 4311450*S^2*n.^6 + 54324270*S^2*n.^5 - 126756630*S^2*n.^4 + 295765470*S^2*n.^3 - 1032161130*S^2*n.^2 + 719149860*S^2*n + 136465347*S^2 - 2402400*C*S*n.^6 + 30270240*C*S*n.^5 - 70630560*C*S*n.^4 + 164804640*C*S*n.^3 - 575134560*C*S*n.^2 + 400720320*C*S*n + 907226320*C*S))/(38745907200*(2*B - 1)) + (n*(n - 1)*(140*M1^2 + 417*S + 6*A*S)*(560*C - 1416*S*A - 1188*S*A^2 + 1005*S))/(22579200*(2*B - 1)^2) - (n*(n - 1)*(2*A - 1)*(42240*A^2*S^2*n.^13 - 1363200*A^2*S^2*n.^12 + 14235936*A^2*S^2*n.^11 - 55551600*A^2*S^2*n.^10 + 109366608*A^2*S^2*n.^9 - 121984512*A^2*S^2*n.^8 + 85342608*A^2*S^2*n.^7 - 50163048*A^2*S^2*n.^6 + 36721464*A^2*S^2*n.^5 - 25596792*A^2*S^2*n.^4 + 11640408*A^2*S^2*n.^3 - 3254472*A^2*S^2*n.^2 - 19456*A^2*S^2*n + 228356*A^2*S^2 + 1921920*A*M1^2*S*n.^7 - 27483456*A*M1^2*S*n.^6 + 70534464*A*M1^2*S*n.^5 - 70726656*A*M1^2*S*n.^4 + 30174144*A*M1^2*S*n.^3 - 10186176*A*M1^2*S*n.^2 + 5957952*A*M1^2*S*n - 2978976*A*M1^2*S - 42240*A*S^2*n.^13 + 1363200*A*S^2*n.^12 - 14235936*A*S^2*n.^11 + 55551600*A*S^2*n.^10 - 109366608*A*S^2*n.^9 + 121984512*A*S^2*n.^8 - 79576848*A*S^2*n.^7 - 32287320*A*S^2*n.^6 + 174881928*A*S^2*n.^5 - 186583176*A*S^2*n.^4 + 78882024*A*S^2*n.^3 - 27304056*A*S^2*n.^2 - 5209040*A*S^2*n + 2385892*A*S^2 + 8072064*M1^4*n - 4036032*M1^4 - 960960*M1^2*S*n.^7 + 13741728*M1^2*S*n.^6 - 35267232*M1^2*S*n.^5 + 35363328*M1^2*S*n.^4 - 15087072*M1^2*S*n.^3 + 5093088*M1^2*S*n.^2 + 45453408*M1^2*S*n - 22726704*M1^2*S + 10560*S^2*n.^13 - 340800*S^2*n.^12 + 3558984*S^2*n.^11 - 13887900*S^2*n.^10 + 27341652*S^2*n.^9 - 30496128*S^2*n.^8 + 18452772*S^2*n.^7 + 28684422*S^2*n.^6 - 96621330*S^2*n.^5 + 99690786*S^2*n.^4 - 42351114*S^2*n.^3 + 14465646*S^2*n.^2 + 75257960*S^2*n - 37574323*S^2))/(29059430400*(6*B - 1)^3) + (6073*S^2*n*(2*A - 1)^3*(2*n.^2 - 3*n + 1))/(4843238400*(6*B - 1)^4) + (n*(n - 1)*(2*A - 1)*(10696224*A^2*S^2*n.^10 - 389760*A^2*S^2*n.^11 - 92738016*A^2*S^2*n.^9 + 289339680*A^2*S^2*n.^8 - 382851840*A^2*S^2*n.^7 + 161755080*A^2*S^2*n.^6 + 94089768*A^2*S^2*n.^5 - 102378504*A^2*S^2*n.^4 + 19038792*A^2*S^2*n.^3 + 2942712*A^2*S^2*n.^2 + 8259088*A^2*S^2*n - 4377356*A^2*S^2 + 6918912*A*M1^2*S*n.^9 - 114162048*A*M1^2*S*n.^8 + 381693312*A*M1^2*S*n.^7 - 491819328*A*M1^2*S*n.^6 + 219675456*A*M1^2*S*n.^5 + 74378304*A*M1^2*S*n.^4 - 111279168*A*M1^2*S*n.^3 + 25657632*A*M1^2*S*n.^2 + 9321312*A*M1^2*S*n + 4276272*A*M1^2*S + 389760*A*S^2*n.^11 - 11928000*A*S^2*n.^10 + 134749440*A*S^2*n.^9 - 658715232*A*S^2*n.^8 + 832214208*A*S^2*n.^7 + 751390608*A*S^2*n.^6 - 2777913456*A*S^2*n.^5 + 2795558448*A*S^2*n.^4 - 1456449312*A*S^2*n.^3 + 442527768*A*S^2*n.^2 - 6463840*A*S^2*n - 4363012*A*S^2 + 48432384*M1^4*n.^3 - 72648576*M1^4*n.^2 - 14990976*M1^4*n + 19603584*M1^4 - 3459456*M1^2*S*n.^9 + 57081024*M1^2*S*n.^8 - 190846656*M1^2*S*n.^7 + 245909664*M1^2*S*n.^6 - 109837728*M1^2*S*n.^5 - 49297248*M1^2*S*n.^4 + 370450080*M1^2*S*n.^3 - 212612400*M1^2*S*n.^2 - 342822480*M1^2*S*n + 239591352*M1^2*S - 97440*S^2*n.^11 + 3289944*S^2*n.^10 - 44190216*S^2*n.^9 + 257022696*S^2*n.^8 - 320394144*S^2*n.^7 - 416134074*S^2*n.^6 + 1365434286*S^2*n.^5 - 1408508886*S^2*n.^4 + 1232004990*S^2*n.^3 - 167513130*S^2*n.^2 + 98680564*S^2*n + 63492001*S^2 - 1921920*C*S*n + 960960*C*S))/(58118860800*(6*B - 1)^2);
%FA=F0+F1+F2;

1 个评论

Sorry for the mix up. All commented equations should be uncommented. Thank you.

请先登录,再进行评论。

 采纳的回答

KSSV
KSSV 2017-5-1
编辑:KSSV 2017-5-1
Check carefully element wise multiplication i.e .* I have modified for F0, you do it for F1 and F2.
A=2;
S=1;
Nt=0.2;
Nb=0.2;
B=0.01; % Beta
Y=0.1; %Gamma
Le=1;
Pr=1.0;
M1=0;
C=-1;
n=1:0.1:2;
F0 =A + n/2 - (A.*n) - (n.*((2*A) - 1).*((2*n.^2) - ((3*n) + 1)))/(2*((6*B) - 1));
Else abs the equations are big, you may consider running loop and then go for vectorizing.

更多回答(1 个)

a) The code you've posted does not include any multiplication in any of the non-commented lines. Therefore it cannot result in the error reported. Are we to assume that the commented lines shouldn't be commented? If so, which ones?
b) Assuming, all should be uncommented, learn to use matlab. In particular, matrix and vector multiplication so you don't have to write and check for errors such complex equations.
c) Learn the difference between matrix and element-wise operations. In your F0, the expression
F0 = ... + (n*(...)) * ((2*n.^2) ...)
^
|
is not valid at the indicated position. It could work with .*
There may be some other locations in your expressions where there's a problem. You'll have to find them yourself, your expressions are too long.

类别

在 帮助中心 和 File Exchange 中查找有关 Biomedical Imaging 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by