MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
Asked by Shing on 12 Jan 2013

Hi all,

I have been trying to solve this problem. To set up a e array[200 by 200] to create some mesh beam diagram. ' However,I keep on receiving this error message:

"??? Undefined function or method 'int' for input arguments of type 'double'." on the integration (int) part no matter how many times I tried.

i tried using quadgk function as searched on the net, but the same message appears.

I wish to obtain numeric integration answer, so I didn't use syms x.

Really appreciate your help !

e=zeros(200); %store the calculated value in e array

double x;

for i=1:1:200

for j=1:1:200

x=i-100;

y=j-100;

rho=sqrt(x^2+y^2); %To generate rho values to sub into e equation

e(i,j)=double(int(cos(x)^0.5*sin(2*x)*((exp(1)^(-(9/4)*(sin(x)/sin(1.125))^2))*(besselj(1,3*(sin(x)/sin(1.125)))))*(besselj(1,2*3.142*rho*sin(x))),0,1.125));

end end

% %

*No products are associated with this question.*

Answer by Walter Roberson on 12 Jan 2013

Accepted answer

You appear to be attempting to do numeric integration. int() is only for symbolic integration. There are a number of numeric integration routines such as quadgk()

Side note:

double x;

would be the same thing as

double('x');

which would convert the letter 'x' to double precision and then throw away the result.

MATLAB does not use declarations of type. Dataypes are determined by assignment.

Shing on 12 Jan 2013

Hi, yes. I'm trying to do numeric integration and tried using quadgk() previously. However, when I did so, I got this error: ??? Undefined function or method 'quadqk' for input arguments of type 'function_handle'. I'm not sure where it went wrong :( Please help ! Thank you in advance!

e=zeros(200);

for i=1:1:200 %range will be -100 to 100 for x column for j=1:1:200 x=i-100; y=j-100; rho=sqrt(x^2+y^2); e(i,j)= quadqk(@myfun,0,1.125);

-------------functionfile------------------------------------------------------------------------------------------------------------ function z = myfun(x)

z= (cos(x)^0.5.*sin(2*(x)).*((exp(1)^(-(9/4)*(sin(x)./sin(1.125))^2))*(besselj(1,3*(sin(x)./sin(1.125))))).*(besselj(1,2.*3.142.*rho.*sin(x))));

## 0 Comments