- What is the value and dimension of the variable "vec"?
- What are the values for the variables "a" and "b"?
- What changes did you exactly make in "func3"?
Info
This question is closed. Reopen it to edit or answer.
Problems with vectorization during minimization/integration
1 view (last 30 days)
Show older comments
Hi,
I have a problem with vectorization during the minimization and/or integration in my code. This is probably very specific, but I'm asking anyways in the hope of getting any hints. I'm trying to compute the following loop:
for y = 1:Y
func_min = @(x)( func1(x, y) )
result = fminbnd(func_min, 0, 1)
end
where
function func1(x, y)
func1 = integral(func2, a, b)
and
func2 = @(y)( func3(x, y)*vec )
and
function func3(x, y)
func3 = [x, x^2, x^3, y, y^2, y^3]
Which is to say that I am trying to minimize a function that contains an integral, and the integrand of that integral is in itself a function of the variable I'm integrating over as well as the variable I'm minimizing over. I already got a great answer regarding a problem during the integration step here, and I've rewritten func3 accordingly, so that whatever the integral function passes as argument for y, the following matrix multiplication works. Now however I run into trouble during the minimization step (I think), as the program again exits with a matrix multiplication error. When I check the dimensions of variable x afterwards, I find that it is a 1x40 cell, where each element itself is of dimension 12 10 8 13. I tried to vectorize things using gdivide, gsubtract etc. instead of the regular operators, but it doesn't seem to work.
I understand that this is a somewhat long and specific question, but I'd appreciate any hints!
Thanks,
Nils
2 Comments
Aniruddha Katre
on 18 Aug 2014
I tried to reproduce the error you are receiving by using the information you provided. But it seems like there is some important information missing from the function definitions you have provided.
Can you provide a more detailed version of the code you are executing as well as the exact error message you are receiving? This information will help resolve the question much faster.
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!