Floating-point scalars

조회 수: 1 (최근 30일)
jack carter
jack carter 2017년 8월 26일
편집: John D'Errico 2017년 8월 26일
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?
  댓글 수: 1
jack carter
jack carter 2017년 8월 26일
편집: jack carter 2017년 8월 26일
even if i take
max_zlimit=z0;
i still cant go through the integration

댓글을 달려면 로그인하십시오.

답변 (2개)

Star Strider
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.

John D'Errico
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.

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by