필터 지우기
필터 지우기

Integrating indefinite integrals without Symbolic

조회 수: 3 (최근 30일)
Robin Seibel
Robin Seibel 2014년 4월 1일
답변: Mike Hosea 2014년 4월 9일
I'm looking for examples of code that demonstrate plotting an indefinite integral without using symbolic solution.

채택된 답변

Mike Hosea
Mike Hosea 2014년 4월 9일
First of all, when working with indefinite integrals numerically, we will need to fix the constant of integration. This is usually done indirectly by selecting the starting point of the integration, e.g. a = 1 for the natural logarithm
ln_scalar = @(x)integral(@(t)1./t,1,x);
I named it "ln_scalar" because it turns out that this definition will only work for scalar values of x. It's easy to extend it to array values, however, so the function we wanted all along is
ln = @(x)arrayfun(ln_scalar,x);
Now we can evaluate ln(x) for arrays of x in MATLAB and hence plot it if we like
x = linspace(0.5,10);
plot(x,ln(x));
Since the repeated integrations here have overlapping intervals, it is possible to be more efficient by integrating only between the points to be plotted and then use CUMSUM to form the function values, but such a solution presupposes that we know all the output points up front.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by