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
Show older comments
%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 Comments
Daniel M
on 4 Apr 2016
Torsten
on 4 Apr 2016
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
on 4 Apr 2016
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.
Answers (1)
Torsten
on 4 Apr 2016
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.
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!