Help with integral2 calculator

조회 수: 14 (최근 30일)
kd
kd 2018년 4월 21일
댓글: Star Strider 2018년 4월 22일
I'm trying to create a basic double integral calculator. How do I refine the code I have so far?
fun = @(x,y) input('enter integrand = ')
xmin = @(y) input('enter lower x boundary = ')
xmax = @(y) input('enter upper x boundary = ')
ymin = @(x) input('enter lower y boundary = ')
ymax = @(x) input('enter upper y boundary = ')
Q = integral2(fun,xmin,xmax,ymin,ymax)

채택된 답변

Star Strider
Star Strider 2018년 4월 21일

Use the str2func (link) function. I would also use vectorize (link):

fun = input('enter integrand = ', 's') 
fun = str2func(['@(x,y) ' vectorize(fun)])
Q = integral2(fun, xmin, xmax, ymin, ymax)
  댓글 수: 3
kd
kd 2018년 4월 22일
Thank you so much. You probably saved me 3 days of trial and error.
Star Strider
Star Strider 2018년 4월 22일
As always, my pleasure!
This is an interesting problem.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by