How can i use integral2 for a vector-valued function ? help please...
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
for example i wrote this code:
%
f=@(x,y)x+y;
g=@(x,y)x^2+y^2;
h=@(x,y)x/y+y/x;
w=@(x,y)sin(x)+cos(y);
box=@(x,y)[f(x,y) g(x,y);h(x,y) w(x,y)];
answers=integral2(box,1,2,1,2)
i expected answers to be a 2*2 scalar matrix but i got only error... what to do?
hint:
Here f,g,h,w and their boundary conditions were only some simple examples.In my real code they are not only too complicated but also inseparable from their vector-valued function unless i define x,y as symbloic variables and separate them by calling function in symbolic variables( i do not want this because its too slow...). I also tested using integral twice instead of integral2 but this method was very very slow too.
my whole code depends on this integral and using reported methods cost me lots of time :(
i wonder why MATLAB does not support 'ArrayValued' option for integral2 :(
what can i do now ?
0 Kommentare
Antworten (1)
Star Strider
am 8 Sep. 2015
In a word, No! The integral2 function does not support array-valued functions.
I thought we covered this in your previous Question: how can i use integral2 for a vector-valued function ?.
Please post the code for a function you want to integrate in your ‘real code’. What about it conforms to the integral function definition of 'ArrayValued'?
2 Kommentare
Star Strider
am 9 Sep. 2015
Your code is difficult for me to follow. I also do not know whether you intend matrix or array (element-wise) operations in your code. (See the documentation on Array vs. Matrix Operations for details.)
Many of the elements appear to be matrices, and you cannot use integral2 to integrate 'ArrayValued' functions. You have to use iterated calls to integral instead, with 'ArrayValued',1 as arguments to it, but only if it matches the definition of 'ArrayValued' in integral. You might have to integrate the individual elements of your matrix separately, as I did with your example code, then reassemble them into your result matrix in the end.
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!