Floating-point scalars
2 次查看(过去 30 天)
显示 更早的评论
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?
回答(2 个)
Star Strider
2017-8-26
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.
0 个评论
John D'Errico
2017-8-26
编辑:John D'Errico
2017-8-26
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!