# Floating-point scalars

6 views (last 30 days)
jack carter on 26 Aug 2017
Edited: John D'Errico on 26 Aug 2017
I need to integrate the following with the given limits,
Lf=12;E=22000;rou=1.2;d=0.039;L=2;v=0:0.01:L;phi=0:0.01:pi/2;
s=v/(Lf/2);
z0=1-sqrt([(E/rou)*(d/L)*(s)]);
max_zlimit=z0.*cos(phi);
fun1=@(z) z*1/Lf;
Q1=integral(fun1,0,max_zlimit);
Can someone please tell me how it can be done?
jack carter on 26 Aug 2017
Edited: jack carter on 26 Aug 2017
even if i take
max_zlimit=z0;
i still cant go through the integration

Star Strider on 26 Aug 2017
I am not certain what you want to do, so I’m taking my best guess at it.
This runs:
Lf=12;
E=22000;
rou=1.2;
d=0.039;
L=2;
N = 50;
v= linspace(0,Lf,N);
phi= linspace(0,pi/2,N);
s=v/(Lf/2);
z0=1-sqrt((E/rou)*(d/L)*s);
max_zlimit=z0.*cos(phi);
fun1=@(z) z*1/Lf;
Q1 = arrayfun(@(z)integral(@(z)fun1(z),0,z), max_zlimit);
The arrayfun function substitutes the values in ‘max_zlimit’ in your integral call, and returns the vector of results.
I defer to you to determine if it gives the output you want.

John D'Errico on 26 Aug 2017
Edited: John D'Errico on 26 Aug 2017
Um, lets be serious. You are trying to integrate the "function" z/Lf, over simple limits. Lf is 12. With limits of 0 and max_zlimit, the integral is trivial.
Q1 = max_zlimit.^2/24
Your problem is that what you want to do is not clear. Since v and phi have different lengths as a vector, I'll guess that what you want is all combinations of those two vectors as the upper limit.
Lf=12;E=22000;rou=1.2;d=0.039;L=2;v=0:0.01:L;phi=0:0.01:pi/2;
s=v/(Lf/2);
z0=1-sqrt([(E/rou)*(d/L)*(s)]);
We can get the array (thus all combinations of the two vectors) using a simple outer product.
max_zlimit=(z0.')*cos(phi);
So now the integral is trivial. We need never bother using a numerical integration scheme like integral.
Q1 = max_zlimit.^2/24;
So Q1 is an array, the desired integral for all combinations of the two vectors.
size(Q1)
ans =
201 158
By the way, integral is not designed to handle vector or array limits of integration anyway.

### Categories

Find more on Linear Algebra 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!