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

Sir I need to calculate different values of the integral L for different values of d.So I cannot use trapz function.
With respect to which variable do you want to integrate ? There is no "formal" integration variable in your formula "sqrt(...".
Best wishes
Torsten.
I have altered the above code.Can you please tell me how to integrate with respect to ls? 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); ls=75*1E-6; %DISPLACEMENT CALCULATION% for i=1:length(d) n(i)=(3.14*d(i)/(2*ls)); m(i)=sqrt(1+((n(i)).^2*(sin(n(i))).^2)); p(i)=@ (ls) m(i); q(i)=integral(p(i),0,ls);
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개)

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에 대해 자세히 알아보기

질문:

2016년 4월 4일

편집:

2016년 4월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by