How to integrate this function numerically?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hello everyone,
I'm stuck at this equation and I want to integrate it numerically
where
and r = 695510, a = -0.0021, b = 1.34, Wo = 438.1
I need to integrate the first equation numerically to get V as a function of R
Numerical integration from R = 10, where it is assumed V = U, to 215 should give V(R).
I appreciate your help.
Thank you,
댓글 수: 2
Is e the base of the natural logarithms? And is it acting as a constant multiplier or is e being raised to the part after it?
Mohamed Nedal
2019년 12월 14일
Yes that's right, it's the base of the natural logarithm and it's being raised to the part after it.
채택된 답변
Chuguang Pan
2019년 12월 14일
You can use Euler formula. V(n+1)=V(n)+h*f(R,V(n)), which f(R,V) is the right side of differential equation.
But you need to know the initial value V(10).
r=695510;a=-0.0021;b=1.34;Wo=438.1;
h=0.1;%Integral step size, you can change this value
N=100;%It means that you want to integral from 10 to 10+h*N
V=zeros(1,N+1);%Initialization V array
V(1)=?;%Need to know the initial value V(10)
for n=1:N
R=10+(n-1)*h;
W=Wo*sqrt(1-exp(1)*(2.8-R)/8.1);
V(n+1)=V(n)+h*r*a*R^(-b)*(1-W/V(n));
end
X=10+(0:N)*h;
Y=V;
plot(X,Y);
댓글 수: 12
Mohamed Nedal
2019년 12월 14일
편집: Mohamed Nedal
2019년 12월 14일
Thanks for your response. The initial value of V(10) is known (693).
I think the 3rd line of the for loop should be like this
W=Wo*sqrt(1-exp((2.8-R)/8.1));
Could you please elaporate on h and N?
What are the consequences of changing the integral step size (h) and N?
r=695510;a=-0.0021;b=1.34;Wo=438.1;
h=0.1;%Integral step size, you can change this value
N=(215-10)/h;%It means that you want to integral from 10 to 215
V=zeros(1,N+1);%Initialization V array
V(1)=693;%Need to know the initial value V(10)
for n=1:N
R=10+(n-1)*h;
W=Wo*sqrt(1-exp((2.8-R)/8.1));
V(n+1)=V(n)+h*r*a*R^(-b)*(1-W/V(n));
end
X=10+(0:N)*h;
Y=V;
plot(X,Y);
you can decrease h for increasing presision
Mohamed Nedal
2019년 12월 14일
Thank you so much, that's very helpful.
Mohamed Nedal
2019년 12월 14일
Please I have another question. Knowing the above parameters, How do we get t from the folowing equation?
Chuguang Pan
2019년 12월 14일
If t is independent variable, it is similar to R. You need to decide for youself.
Such as t=t0+(0:N)*h.
Mohamed Nedal
2019년 12월 14일
편집: Mohamed Nedal
2019년 12월 14일
t is the time (in seconds) the object takes to cross the distance R at speed V.
to = 0, I need to find t(R=215).
Could you check this please.
r = 695510; a = -0.0021; b = 1.34; Wo = 438.1;
h = 1; % Integral step size, you can change this value
N = (215 - 10)/h; % It means that you want to integral from 10 to 215
V = zeros(1,N+1); % Initialization V array
t = zeros(1,N+1);
t(1) = 0;
V(1) = 693; % Need to know the initial value V(10)
for n = 1:N
R = 10 + (n-1)*h;
W = Wo * sqrt(1-exp((2.8-R)/8.1));
V(n+1) = V(n) + h*r*a*R^(-b)*(1-W/V(n));
t(n+1) = t(n) + h*a*R^(-b)*(V(n)-W);
end
X = 10 + (0:N)*h;
t = (0:N)*h; % to = 0
plot(X,V);
t here is monotonically increasing (t=0,1,2,...) and when I removed this line
t = (0:N)*h;
it gives negative fractions and it's not correct.
V=dR/dt. dt=dR/V.
R=10+(0:N)*h;
dR=diff(R);
V=(V(2:end)+V(1:end-1))*0.5;%average speed
dt=dR./V;
t=[0 cumsum(dt)];
Mohamed Nedal
2019년 12월 14일
Thank you very much :)
Excuse me another question..
I would like to apply this equation on several objects and I tried to replace V(1), which's the initial value V(10), with a vector column instead of a single value like this one for instance
Vtest = [136
490
359
361
693
1374
585
542
1118
910
1188];
so that each value is assigned for one object. But I got this error
In an assignment A(:) = B, the number of elements
in A and B must be the same.
Error in numeric_integ (line 22)
V(1) = Vtest; % Need to know the initial value V(10)
Could you help me out?
and if I want to find only the value of V(215) and t(215), which are the last values of V and t at distance 215, how can I do that?
result_V=zeros(1,length(Vtest));% save last V for every Vtest
result_t=zeros(1,length(Vtest));% save last t for every Vtest
for i=1:length(Vtest) %for every Vtest
V=zeros(1,N+1);
V(1)=Vtest(i);
%do the computing
result_V=V(end); %using end to index last value of array V
result_t=t(end); %using end to index last value of array t
end
Mohamed Nedal
2019년 12월 15일
Thank you so much
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
