From: Jonas Knudsen on
I am calculating the damping force of a permanent magnet. The damping force is called F in my code. F is calculated as a dobbeltintegration over to variabels y and z1.

The problem is that the inner integral (variable z1) needs to be ^2. The integration I would like to perform looks like this:

F= constant*int(int( "(se code)",z1=-10...0)^2,y=0...1.1)

I use dblquad and It works fine, but I can only figure out how to calculate:

F= constant*int(int( "(se code)",z1=-10...0),y=0...1.1)
or
F= constant*int(int( "(se code)"^2,z1=-10...0)^2,y=0...1.1)

Will be thankful for any help /Jonas

File 1:
function z = integrnd(y,z1)


b=1;lg=1;

%As the integral is large I use these dobbelt letters to secure better overview.
AA=(lg-z1); %scalar
BB=2*(b^2+y.^2+(lg-z1)^2);
CC=mfun('EllipticE',2*sqrt(-y*b./(b^2-2*b*y+y.^2+(lg-z1)^2)));
DD=2*((b+y).^2+(lg-z1)^2).^2;
EE=mfun('EllipticK',2*sqrt(-y*b./(b^2-2*b*y+y.^2+(lg-z1)^2)));
FF=b*sqrt(b^2-2*b*y+y.^2+(lg-z1)^2).*((b+y).^2+(lg-z1)^2).^2;

%This is the function which have to be integrated
z = ((AA*(BB.*CC-DD.*EE))./FF);

File 2:

clc
tic
b=1;lg=1;rc=1.1;L=10;sigma=1;
delta=1;v=1;mu0=1;M0=1;
k=[0 0 1];

konst=-2*k*pi*sigma*delta*v*1/(16*pi^2)*mu0^2*M0^2*b^2;
F = konst*dblquad(@integrnd, 0, rc, -L, 0) %Husk at det er rc og L
toc
From: Jonas Knudsen on
"Jonas Knudsen" <s071971(a)student.dtu.dk> wrote in message <hnd8e9$hh6$1(a)fred.mathworks.com>...
> I am calculating the damping force of a permanent magnet. The damping force is called F in my code. F is calculated as a dobbeltintegration over to variabels y and z1.
>
> The problem is that the inner integral (variable z1) needs to be ^2. The integration I would like to perform looks like this:
>
> F= constant*int(int( "(se code)",z1=-10...0)^2,y=0...1.1)
>
> I use dblquad and It works fine, but I can only figure out how to calculate:
>
> F= constant*int(int( "(se code)",z1=-10...0),y=0...1.1)
> or
> F= constant*int(int( "(se code)"^2,z1=-10...0)^2,y=0...1.1)
>
> Will be thankful for any help /Jonas
>
> File 1:
> function z = integrnd(y,z1)
>
>
> b=1;lg=1;
>
> %As the integral is large I use these dobbelt letters to secure better overview.
> AA=(lg-z1); %scalar
> BB=2*(b^2+y.^2+(lg-z1)^2);
> CC=mfun('EllipticE',2*sqrt(-y*b./(b^2-2*b*y+y.^2+(lg-z1)^2)));
> DD=2*((b+y).^2+(lg-z1)^2).^2;
> EE=mfun('EllipticK',2*sqrt(-y*b./(b^2-2*b*y+y.^2+(lg-z1)^2)));
> FF=b*sqrt(b^2-2*b*y+y.^2+(lg-z1)^2).*((b+y).^2+(lg-z1)^2).^2;
>
> %This is the function which have to be integrated
> z = ((AA*(BB.*CC-DD.*EE))./FF);
>
> File 2:
>
> clc
> tic
> b=1;lg=1;rc=1.1;L=10;sigma=1;
> delta=1;v=1;mu0=1;M0=1;
> k=[0 0 1];
>
> konst=-2*k*pi*sigma*delta*v*1/(16*pi^2)*mu0^2*M0^2*b^2;
> F = konst*dblquad(@integrnd, 0, rc, -L, 0) %Husk at det er rc og L
> toc

If the description of the problem is unclear please let me know. /Jonas
From: Bruno Luong on
What's wrong with calling an inner quad, square it, and calling an outer quad on the square?

Bruno
From: Jonas Knudsen on
"Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hnfiet$d2s$1(a)fred.mathworks.com>...
> What's wrong with calling an inner quad, square it, and calling an outer quad on the square?
>
> Bruno

Hey Bruno

Thanks for the reply.

I think what your're saying is possible, but I am not very used to using MATLAB.
I have two varibels z1 and y. The problem with using a single "quad" is that only 1 variable is defined (y), and MATLAB tells me that z1 is undefined.

Jonas
From: Bruno Luong on
You need to pass z1 as function "parameter" of a function that integrate with respect to "y". The syntax help page is here:

http://www.mathworks.de/access/helpdesk/help/techdoc/math/bsgprpq-5.html

Bruno
 |  Next  |  Last
Pages: 1 2
Prev: 3D Matrix access in Mex files
Next: help