I need to implement the following formula in my code but getting an error as "First input argument must be a function handle."How do i proceed? a nd v has been defined in prior
이전 댓글 표시
%ELONGATION CALCULATION% P=[0,0.1*1E8,0.2*1E8,0.3*1E8,0.4*1E8,0.5*1E8,0.6*1E8,0.7*1E8,0.8*1E8,0.9*1E8,1*1E8] for i=1:length(P) d(i)=((3*P(i)*a^4)*(1-v^2))/(1.5660216*1E-4) end figure; plot(P,d);
%DISPLACEMENT CALCULATION% for i=1:length(d) L(i)=2*(integral(sqrt(1+(((3.14*d(i))/(2*75*1E-6))^2)*(sin((3.14*d(i))/(2*75*1E-6)))*(sin((3.14*d(i))/(2*75*1E-6)))),0,75*1E-6)); end
댓글 수: 4
Daniel M
2016년 4월 4일
Torsten
2016년 4월 4일
With respect to which variable do you want to integrate ? There is no "formal" integration variable in your formula "sqrt(...".
Best wishes
Torsten.
Daniel M
2016년 4월 4일
Try this:
P=[0,0.1*1E8,0.2*1E8,0.3*1E8,0.4*1E8,0.5*1E8,0.6*1E8,0.7*1E8,0.8*1E8,0.9*1E8,1*1E8];
d=((3*P*a^4)*(1-v^2))/(1.5660216*1E-4);
ls_start=0.0;
ls_end=75*1e-6;
for i=1:length(d)
n=@(ls)3.14*d(i)./(2*ls);
m=@(ls)sqrt(1+n(ls).^2.*(sin(n(ls))).^2);
q(i)=integral(m,ls_start,ls_end);
end
Best wishes
Torsten.
답변 (1개)
Torsten
2016년 4월 4일
For discrete data, use trapz instead of integral:
P=[0,0.1*1E8,0.2*1E8,0.3*1E8,0.4*1E8,0.5*1E8,0.6*1E8,0.7*1E8,0.8*1E8,0.9*1E8,1*1E8];
d=((3*P*a^4)*(1-v^2))/(1.5660216*1E-4);
x=d;
y=sqrt(1+(((3.14*x)/(2*75*1E-6)).^2).*(sin((3.14*x)/(2*75*1E-6))).*(sin((3.14*x)/(2*75*1E-6))));
cumulated=trapz(x,y);
Best wishes
Torsten.
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!