|
Hello ,
Thanks a lot for your response ,
First,
I am exactly using this program no details is missing
In one m file i am just writing the two simulataneous equations
as
function F = myyfun(x)
F = [2*x(1) -k* x(2) - exp(-x(1));
-x(1) + 2*x(2) - exp(-x(2))];
Nothing else i am writting,now on a different m file i am just writting
x0 = [-5; -5];
for k=1:1:10
[x] = fsolve(@myyfun, x0)
x0=[x]
end
The error shown is this
??? Error using ==> feval
Error: File: myyfun.m Line: 3 Column: 19
Expression or statement is incomplete or incorrect.
Error in ==> fsolve at 254
fuser = feval(funfcn{3},x,varargin{:});
Error in ==> myfunrun at 4
[x] = fsolve(@myyfun, x0)
Caused by:
Failure in initial user-supplied objective function
evaluation. FSOLVE cannot continue.
I am new to this , and it might be stupid to ask , but help will be appreciated i wanna see how it works for this simple problem then can i implement to real problem,.
And i didnt get what you meant by i havent got the value of k ,I am using the for loop in the second m file for that , am i wrong ?
SD
"John D'Errico" <woodchips@rochester.rr.com> wrote in message <imvsg5$432$1@fred.mathworks.com>...
> "Sayanatn " <sayan.polo@gmail.com> wrote in message <imvrkg$ift$1@fred.mathworks.com>...
> > Hi,
> >
> > I am trying to run this program ..
> >
> > Here i want to initialize the guess ,
> > then i want for different value of k the program automatically get the previous root as the initial for the next one
> >
> > How can i do so
> >
> > EXample:
> >
> >
> > function F = myyfun(x)
> >
> >
> > F = [2*x(1) -k* x(2) - exp(-x(1));
> > -x(1) + 2*x(2) - exp(-x(2))];
> > (*The k is changing suppose from 1-10 with an increment of 1)
> >
> > On another mfile i write
> >
> > x0 = [-5; -5];
> >
> > for k=1:1:10
> > [x] = fsolve(@myyfun, x0)
> > x0=[x]
> > end
> >
> > Not working , what should i do?
> >
> > Please help
> > (I want the first output of root to be the input for the guess for the second one)
>
> What makes you think it is not working?
>
> That will indeed use the previous value of x as the
> start point x0.
>
> Perhaps you are not updating k in your function?
> You need to give us a better ACTUAL example of
> non-working code for us to help you.
>
> And then tell us what did not work!
>
> John
|