Re: script callng created function within the script



If you make your function B a separate file called
functionname.m you will not have this trouble. As far as I
know it shouldn't really slow anything down either to have
it in a separate file. Otherwise make script A a function -
functions within functions should be recognized. (you can
simply add the first line to file A of

function bogus=A()
{insert old script A and subfunction B here}
return;

I prefer the first way because it leaves your variables
accessible outside the function call which simplifies de-bugging

"Jerzy Nowakowski" <j.nowakowski@xxxxxxxx> wrote in message
<fe0jr0$bsb$1@xxxxxxxxxxxxxxxxxx>...
Hi,

within script "A" I created the function B, which then is
called using "eval" expression:

[x,resnorm] = lsqcurvefit(eval(['@'
funname]),x0,values_x,values_y,0,300,options);

I have to run the script "A" twice, because the lsqcurvefit
does not recognize the function created by the first pass.
I tried to add the line with load, like this:

load (funname);
[x,resnorm] = lsqcurvefit(eval(['@'
funname]),x0,values_x,values_y,0,300,options);

It didn't help. I still have to pass the script two times.

Thanks for help


.



Relevant Pages

  • Re: Gnuplot 4.2: Animated GIFs
    ... I am a bit confused about the demo script at the Gnuplot site, ... out they call a separate file "gnuplot.rot". ... All of these demos are distributed with gnuplot, ... "Are you trying to make a plot like the one at URL? ...
    (comp.graphics.apps.gnuplot)
  • Re: Looking for "Terminate Event" in Windows Script Components???
    ... in the usual manner. ... This is a separate file ... right so would it have <script> tags referencing the "packaged" file ... The reason I ask is that there's a difference between "packaging" ...
    (microsoft.public.scripting.wsh)
  • Re: Samba Q?
    ... Since Samba is an SMB server, and cifs an SMB client, I have no idea ... However, if I cat the line from the file, copy & paste it but without the passwd portion and exec it, it then asks me for it, and its fine with that long a passwd from the interactive shell. ... Why can't I put it in the script? ... user and password stored in a separate file? ...
    (Fedora)
  • Re: Design Model Question
    ... this architecture is one of the leading ... > The proper way to share code between script is to enclose it in functions, ... > keep these in an separate file, include it where it's needed, then call ... A single entry point architecture is sometimes known as a Front Controller ...
    (comp.lang.php)
  • Re: script callng created function within the script
    ... I create function B from script A dynamically - it means, ... how to tell matlab to load the ... it in a separate file. ...
    (comp.soft-sys.matlab)