[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using fsolve() for a function involving quad()?
From: |
Minyu Chen |
Subject: |
Using fsolve() for a function involving quad()? |
Date: |
Tue, 12 Jun 2007 19:09:40 +0100 |
Dear all:
I am sorry that the question might sound a bit silly.
I need to solve a function involving integration, so I think I need
both quad()--for the integration and fsolve()--for the equation.
However, the integrand involve the unknown.
For a trivial example, I want to solve: x+\int_{0}^{1}x*y dy=0
I was thinking of taking a function:
function w=f(y)
w=x.*y;
endfunction
Then I use another function:
function z=g(x)
z=quad('f',0,1)+x;
endfunction
Then I use: fsolve('g',0.5). But it didn't work.
The error message is that the "x" is not defined in my f function.
However, I called "f" only in the function "g", and the x in the
function "g" is already initialized as 0.5 in the searching. What
went wrong?
Thank you very much.
Thanks,
Minyu Chen
- Using fsolve() for a function involving quad()?,
Minyu Chen <=