On 12/23/2012 7:28 AM, Tian wrote:
> I am a programmer but am new to the syntax of matlab.
> I wonder how I could fsolve a system of nonlinear functions. Here is my code:
>
I think fsolve wants numbers, not symbols. Try with actual numbers.
also your code posted is not complete.
> x = X(i1)
> y = Y(i1)
> a = (sqrt(3)1)/(2*sqrt(3))
> b = (sqrt(3)+1)/(2*sqrt(3))
> c = (sqrt(3)2)/(4*sqrt(3))
> d = (sqrt(3)+2)/(4*sqrt(3))
>
> G = @(k)('[k(:,1)  (4*(x + a*h) + y + h/2*k(:,1) + c * h * k(:,2)  1)^(0.5); k(:,2)  (4*(x + b*h) + y + d*h*k(:,1) + h/4*k(:,2) 1)^(0.5)]')
>
> [k, fval] = fsolve(G, [0.0,0.0])
>
>
> Basically, I want to use the two equations to solve for k with k1 and k2....
> But I received the following error message:
>
> Error using fsolve (line 280)
> FSOLVE requires all values returned by user functions to be of
> data type double.
> Error in rk4 (line 26)
> [k, fval] = fsolve(G, [0.0,0.0])
>
> I don't know what's wrong. Thx.
>
