İntegral with array boundaries Need help

3 views (last 30 days)
sarngon on 20 Mar 2015
Answered: Mike Hosea on 22 Mar 2015
Hi Guys ,
I want to write a code which includes an array like x=[1 2 3;4 5 6] and
my function is
f=@(y) (y-x).^2
Q= integral ( f,0,x);
* *I couldn't be successful about it and I need help how can I take an integral over array boundries like this.* *
Thanks. One of members told me to try below command Qscalarx but it dint work for me. I tried it like below (scalar) ,
Qscalarx = @(x)integral(@(w) kr*(in(:,3:4)-w)*(k*l*vi/(wr*ccons))*(((1+p*l)*vi/ccons).^(k-1))*2.71.^((-((1+p*l)*vi/ccons)).^k),0,x);
Q = @(x)arrayfun(Qscalarx,x);
But it didn't work. Am I missing smth ?

Answers (1)

Mike Hosea
Mike Hosea on 22 Mar 2015
I've answered this question in a follow-up comment on the other question. It will work, but you have to debug your code. You were supposed to substitute x for in(:,3:4) in the integrand. Since p is a function of w, you'll need to use p(w) everywhere, and some of your multiplications will need to be changed from matrix multiplication * to element-wise array multiplication .*.


Find more on Resizing and Reshaping Matrices 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!