필터 지우기
필터 지우기

Define function in M file

조회 수: 2 (최근 30일)
Yuchi Kang
Yuchi Kang 2017년 7월 15일
답변: sahil suleman 2020년 2월 28일
Hello Everyone.I want to define two functions in an M file including M and M1. Here is the code. In the end I want to calculate the integration of function M1 from 0 to L. But there is something wrong. Thanks for ur help to beginners like me.
FT=1;
FS=2;
E=3;
d=4;
I=5;
K=sqrt(FS/E/I);
L=2;
B=-FT/FS*L;
A=FT/FS/K;
X=0:L/100:L;
W=A*sin(K*X)+B*cos(K*X)+FT/FS*(L-X);
FT1=0:FT/100:FT;
W1=FT1.*(X.^2)/6/E/I.*(3*L-X);
plot(X,W,'k:',X,W1,'y-')
M= @(X) (FS*(A*sin(K*X)+B*cos(K*X)+FT/FS*(L-X))+FT*(L-X));
M1= @(X) M^2/2/E/I
V=integral(M1,0,L)

채택된 답변

David Goodmanson
David Goodmanson 2017년 7월 15일
편집: David Goodmanson 2017년 7월 16일
Hello Yuchi, M is a function that has one argument, so you need to supply it in M1. Also, it appears that with M1 you wish to square each element in the M array and under this assumption,
M1= @(X) M(X).^2/2/E/I % with .^
  댓글 수: 1
Yuchi Kang
Yuchi Kang 2017년 7월 16일
Thanks a lot. That's what I want

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

sahil suleman
sahil suleman 2020년 2월 28일
find the size , transpose, length of a matrix. pls give me the ans.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!