Help with integral2 calculator

10 views (last 30 days)
kd
kd on 21 Apr 2018
Commented: Star Strider on 22 Apr 2018
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)

Accepted Answer

Star Strider
Star Strider on 21 Apr 2018

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 Comments
kd
kd on 22 Apr 2018
Thank you so much. You probably saved me 3 days of trial and error.
Star Strider
Star Strider on 22 Apr 2018
As always, my pleasure!
This is an interesting problem.

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!