"Mostafa ElHosseini" <melhosseini@yahoo.com> wrote in message <i9fvtv$lve$1@fred.mathworks.com>...
> in the documentation, quad(@f,a,b), and f shoud be a function of x. and x should be a vector.
> my case here that x is a matrix with 7 coulmns
> i.e what would be the case if x is matrix and i need the 1st coulmn, 2nd coulmn, ....
>
> below is my case
>
> function f =fitness(indiv)
> global u1 u2 u3
> [ro,co] = size(indiv);
> score = [];
> for i=1:ro
> eachrow = indiv(i,:);
> u1 = eachrow(:,1); % u1
> u2 = eachrow(:,2); % u2
> u3 = eachrow(:,3); % u3
> PI = quad(@fx,0,.2,1e1);
> if (u1 > 20  u2 > 6  u3 > 4)
> PI = PI/10;
> end
> score(i,:)=PI;
> end
> f = score;
> end
> ===================
>
> function [ y] = fx( x )
> global u1 u2 u3
> [t,x] = solveode(u1,u2,u3);
> q = 6.0 + u1 + u2;
> %[t,x] = solveode(u1,u2,u3);
> % write here the performance Index
> y = 5.8*(q*x(:,1)6)3.7*u14.1*u25*u3^2+q*(23*x(:,4)+11*x(:,5)...
> +28*x(:,6)+35*x(:,7))0.099;
>
> end
        
There seems to be some misunderstanding here about how matlab's 'quad' function works. It will send a number of vectors to its function argument according to its own convenience. These vectors can each have element values lying anywhere within the limits of integration and the vectors may have various lengths  whatever it decides is needed to obtain an accurate integral. It would never send a matrix to the function. The function is required to send back the integrand value for each of the points in the vector at each call.
As far as I can make out, that is not at all in accordance with the 'fx' function you describe, which in fact appears to discard the x values it is sent and only makes use of the three global scalars u1, u2, and u3. Also to deepen the mystery, 'solveode' appears to be a mathematica function, not a matlab function.
Could you please clarify your situation?
Roger Stafford
