I want to evaluate the $\int\int\int dxdydz$ using 'integral3' function in MATLAB. But the only code my intuition has helped me it this:
g = @(x,y,z) 1 u = integral3(g,1,2,1,3,1,4) But this results in errors. Please help me create the correct code.
$\endgroup$12 Answers
$\begingroup$integral3 expects the function g to be vectorized, however, g = @(x,y,z) 1 will always return a scalar, no matter the dimensions of the input x, y, or z.
A simple fix:
g = @(x,y,z) 1 + 0*x u = integral3(g,1,2,1,3,1,4) Another example
g = @(x,y,z) x.*y u = integral3(g,1,2,1,3,1,4) $\endgroup$1$\begingroup$clear all clc syms x y z xa=-2; xb=2; ya=-sqrt(2-x^2/2); yb=sqrt(2-x^2/2); za=x^2+3*y^2; zb=8-x^2-y^2; I=int(int(int(1+0*z,z,za,zb),y,ya,yb),x,xa,xb) viewSolid(z,za,zb,y,ya,yb,x,xa,xb) $\endgroup$1