필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

help with numerical integration

조회 수: 1 (최근 30일)
richard
richard 2014년 2월 4일
마감: MATLAB Answer Bot 2021년 8월 20일
I want to numerically integrate a function where a parameter is varied. This is what my code looks like:
y=0:0.0001:30.5;
r=30.5:0.0001:sqrt((y).^2+(25.4)^2);
Sa=3.1381e5;
f=(Sa/2)*(1./(r).*exp(-0.1577534.*r));
F=trapz(r,f)
What I'm trying to tell matlab is to find F for each of the y-values listed. I want matlab to list the array of which y-values were used and the corresponding F for that y-value.
As it is when I enter my code my F is 0.

답변 (1개)

Amit
Amit 2014년 2월 4일
First thing: what are you trying to do with y and r? Your r will be empty as the last value in defining r is a vector.
Can you write down what is the correlation in r and y?
  댓글 수: 2
richard
richard 2014년 2월 4일
편집: richard 2014년 2월 4일
This is what I wanted my 'bounds of integration' to look like, which was what my r was supposed to represent:
y=0:0.0001:30.5;
0 ----> sqrt((0)^2 + (25.4)^2) this corresponds to the F when my y=0
0.0001--->sqrt((0.0001)^2 +(25.4)^2)this corresponds to the F when my y=0.0001
0.0002 --->sqrt((0.0002)^2 + (25.4)^2) this corresponds to the F when my y=0.0002
y_n--->sqrt((y_n)^2 + (25.4)^2) this corresponds to the F when my y=y_n
and so on until my y=30.5
Please let me know if you understand what I am writing out
Amit
Amit 2014년 2월 4일
y=0:0.0001:30.5;
r = sqrt((y).^2+(25.4)^2);
Sa=3.1381e5;
f=(Sa/2)*(1./(r).*exp(-0.1577534.*r));
F=trapz(r,f)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by