MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

0

Error in solving double integration

Vardhan Barve さんによって質問されました 2019 年 3 月 31 日
最新アクティビティ Vardhan Barve さんによって コメントされました 2019 年 3 月 31 日
Hello all i have been trying to solve this double integration with respect to x and y . i have defined all the input parameters and used syms for unknown variables x and y
Problem is that it is not executing fun2 in code and showing error please help me correct the syntax and logic if possible
Code is given below
i=input('\n Input value of i from 1 to infinity : ' );
j=input('\n Input value of j from 1 to infinity : ' );
L1=input('\n Input value of lenth 1 x direction of plate ');
L2=input('\n Input value of lenth 2 y direction of plate ');
h=input('\n Input value of plate thickness ');
a=input('\n Input value of half crack length ');
b=input('\n Input value of angle of crack ');
d=input('\n Input value of crack depth ') ;
u=input('\n Input value of poissons ratio of plate material ');
E=input('\n Input value of Youngs modulus of plate material ');
p=input('\n Input value of density of plate material ');
Cbt=-2.216;
Cbb=-4.4277;
Ctt=11.4870;
z=d/h
Att=(z^2)*Ctt*(z^2)
Abb=(z^2)*Cbb*z
Abt=(z^2)*Cbt*z
D=(E*(h^3))/(12*(1-(u^2)))
syms x
syms y
X=sin((i*3.14*(x))/L1)
Y=sin((i*3.14*(y))/L2)
Xi=diff(X)
Yi=diff(Y)
Xii=diff(Xi)
Yii=diff(Yi)
Xiii=diff(Xii)
Yiii=diff(Yii)
Xiv=diff(Xiii)
Yiv=diff(Yiii)
fun1= (((p*h)/D)*((X^2)*(Y^2)))
fun2= {{{((Xiv)*Y)+(2*(Xii)*(Yii)+(Yiv)*X)}-{((a)*(1+cosd(b))*((Yiv*X)+(u(Xii)*(Yii))))/(((((3)*((Abt/6)+Abb)*(3+u)*(1-u)))*h)+(2*a))}+{(((2*a)*sind(b))*(((Xi)*(Yiii))+(u(Xiii)*(Yi))))/(((3)*((Cbt/6)+Cbb)*(1+u)*h)+(2*a))}}*X*Y}
M=dblquad(fun1,0,L2,0,L1);
M=dblquad(fun2,0,L2,0,L1);

  0 件のコメント

サインイン to comment.

1 件の回答

回答者: John D'Errico
2019 年 3 月 31 日
編集済み: John D'Errico
2019 年 3 月 31 日
 採用された回答

Don't make people guess what error you got. TELL US. Paste in the COMPLETE message, thus everything in red.
Today, on your question, the answer seems clear. I might guess what error you got. And here, I would probably be right. For some reason, you seem to think you can use any kind of parens, brackets, etc in MATLAB. That works in mathematics when you are writing formulas, and to a large extent, MATLAB often mimics mathematical notation. However, in MATLAB, you cannot just randomly choose () sometimes, and {} others. There is a difference. {} are used to create cell arrays.
fun2= {{{((Xiv)*Y)+(2*(Xii)*(Yii)+(Yiv)*X)}-{((a)*(1+cosd(b))*((Yiv*X)+(u(Xii)*(Yii))))/(((((3)*((Abt/6)+Abb)*(3+u)*(1-u)))*h)+(2*a))}+{(((2*a)*sind(b))*(((Xi)*(Yiii))+(u(Xiii)*(Yi))))/(((3)*((Cbt/6)+Cbb)*(1+u)*h)+(2*a))}}*X*Y}
Don't use {} unless you have a valid reason to do so. Here, you don't. Cell arrays are great containers that can hold just about anything. But they cannot be used as easily for computations. So creating a multi-level cell array inside that line caused your failure. Use parens, thus () instead.
In general, know when it is correct to use [], (), and {}. They all do different things in MATLAB, though SOMETIMES you can get away with [] versus (). Know the difference, and you won't need to guess.
A simple set of guidelines is:
  • [] is used to create arrays by catenation.
  • () is used to create or call functions, or as a means to specify order of operations.
  • {} is used to create cell arrays.
I might add these too:
  • ' ' (single quotes) is used to create character vectors.
  • " " (double quotes) is used to create strings

  1 件のコメント

Vardhan Barve 2019 年 3 月 31 日
Thank you john for answering, sorry i did not post the error messgae
I changed { }to () in my code yet some error is showing up as mentioned below
Input value of i from 1 to infinity : 1
Input value of j from 1 to infinity : 1
Input value of lenth 1 x direction of plate 150
Input value of lenth 2 y direction of plate 150
Input value of plate thickness 5
Input value of half crack length 4
Input value of angle of crack 45
Input value of crack depth 3
Input value of poissons ratio of plate material 0.3
Input value of Youngs modulus of plate material 200000
Input value of density of plate material 12000
z =
0.6000
Att =
1.4887
Abb =
-0.9564
Abt =
-0.4787
D =
2.2894e+06
X =
sin((157*x)/7500)
Y =
sin((157*y)/7500)
Xi =
(157*cos((157*x)/7500))/7500
Yi =
(157*cos((157*y)/7500))/7500
Xii =
-(24649*sin((157*x)/7500))/56250000
Yii =
-(24649*sin((157*y)/7500))/56250000
Xiii =
-(3869893*cos((157*x)/7500))/421875000000
Yiii =
-(3869893*cos((157*y)/7500))/421875000000
Xiv =
(607573201*sin((157*x)/7500))/3164062500000000
Yiv =
(607573201*sin((157*y)/7500))/3164062500000000
Error using sym/subsindex (line 732)
Invalid indexing or function definition. When defining a function, ensure that the arguments are symbolic
variables and the body of the function is a SYM expression. When indexing, the input must be numeric, logical,
or ':'.
Here is my modified code
i=input('\n Input value of i from 1 to infinity : ' );
j=input('\n Input value of j from 1 to infinity : ' );
L1=input('\n Input value of lenth 1 x direction of plate ');
L2=input('\n Input value of lenth 2 y direction of plate ');
h=input('\n Input value of plate thickness ');
a=input('\n Input value of half crack length ');
b=input('\n Input value of angle of crack ');
d=input('\n Input value of crack depth ') ;
u=input('\n Input value of poissons ratio of plate material ');
E=input('\n Input value of Youngs modulus of plate material ');
p=input('\n Input value of density of plate material ');
Cbt=-2.216;
Cbb=-4.4277;
Ctt=11.4870;
z=d/h
Att=(z^2)*Ctt*(z^2)
Abb=(z^2)*Cbb*z
Abt=(z^2)*Cbt*z
D=(E*(h^3))/(12*(1-(u^2)))
syms x y integer
X=sin((i*3.14*(x))/L1)
Y=sin((i*3.14*(y))/L2)
Xi=diff(X)
Yi=diff(Y)
Xii=diff(Xi)
Yii=diff(Yi)
Xiii=diff(Xii)
Yiii=diff(Yii)
Xiv=diff(Xiii)
Yiv=diff(Yiii)
fun1 = ( ( (p*h)/d )*( (X^2)*(Y^2) ) );
fun2= (((((Xiv)*Y)+(2*(Xii)*(Yii)+(Yiv)*X))-(((a)*(1+cosd(b))*((Yiv*X)+(u(Xii)*(Yii))))/(((((3)*((Abt/6)+Abb)*(3+u)*(1-u)))*h)+(2*a)))+((((2*a)*sind(b))*(((Xi)*(Yiii))+(u(Xiii)*(Yi))))/(((3)*((Cbt/6)+Cbb)*(1+u)*h)+(2*a))))*X*Y);
M=dblquad(fun1,0,L2,0,L1)
K=dblquad(fun2,0,L2,0,L1)
Please help
Thanking you in advance

サインイン to comment.



Translated by