MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: NotebookGet/Read/EvaluateSelection Issues

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106784] Re: [mg106741] Re: NotebookGet/Read/EvaluateSelection Issues
  • From: Paul Shreeman <pkshreeman at gmail.com>
  • Date: Sat, 23 Jan 2010 07:34:23 -0500 (EST)
  • References: <hj98as$g52$1@smc.vnet.net> <hj9e1n$k6t$1@smc.vnet.net>

David,

Thank you for your explanations and your time.

I made up the simple routines to test out my "theory" of manipulating
notebooks by means of NotebookOpen, SelectionEvaluate, etc...

I am not technically a beginner, but I am aware that Mathematica is very
complex package, and I have been only playing on its surface.  Most of time,
I hated it because of it's confusing programming syntax.  It took me a long
time to realize how the global variables work because I was used to local
variable programming in other language (Fortran90, Basic).  I was trying to
design the Mathematica routines in similar concept to Fortran90 design where
you write modules in separate files, and get called up on whenever it is
needed.

I can complete my simulation, but I use GoTo function to control the looping
around the program and it gets really messy.  What I need is ability to
easily change the parameters to do curve fitting of experimental data with
my mathematical model.  I can do that fine using just a single notebook, but
it is very very inconvenient way of doing it.  I use IF statements to change
parts of my mathematical model parameters for various properties, and also
control some of parameters on top as input.  I just wish I can just use
buttons, drop-downs, check/uncheck and push a button to do the simulations
and/or curve fitting.  Right now, I am at the phase of deciding whether to
just add yet another long routine based on genetic algorithm for automatic
curve fitting procedure (which worked fine in one of my long notebooks).
 The problem, as you can easily see, makes the notebook awfully long and
messy with goto loops, and I would have to rewrite it every time I want to
change parameters and whenever I don't want the automatic fitting to "on".

Let's assume that I have say, three complex working routines in Mathematica
 that needs certain parameter inputs.  Currently, they all are conjoined
together with Label/Goto function with input on top as integral part of
notebook.  What I want to do is add a "front-end" functionality to MY
routines, add some pretty buttons, sliding bar for variables, etc, and
ability to add/remove a routine (say genetic algorithm routine) and hit a
"start button", and ping! there's a pretty graph!  The only missing thing
right now is my ability to separate these routines, put them in a nice
boxes, and call 'em up.  I am going to read about the package more and
double check whether this is exactly what I'm looking for.

Thanks!

Paul






On Fri, Jan 22, 2010 at 9:12 AM, David Park <djmpark at comcast.net> wrote:

> Your situation is a good example of what I have been arguing for some time.
> I get the impression that you are relatively new to Mathematica, or haven't
> used it much? It would be really nice is good students had a chance to
> learn
> Mathematica early so that when they got into university and had significant
> projects such as theses they wouldn't have to wrestle with Mathematica.
>
> It's not true that Mathematica is an application that you can take off the
> shelf and immediately apply to a significant project. There is a rather
> steep learning curve, even for very intelligent people. One solution would
> be to embark on a crash course and go over the basics. Another aid will be
> to keep asking questions on MathGroup but make them more specific. From
> your
> questions so far it appears that you are having difficulty in just writing
> working definitions and algorithms or Modules in Mathematica. There is no
> reason that If statements shouldn't work and using many loops is a little
> suspicious. (Are you comfortable with Functional programming techniques?)
>
> You can write packages in Version 5. (But Version 7 is MUCH nicer.) But
> trying to read results from a bunch of other notebooks is definitely not
> the
> way to do it.
>
> I would forget packages and multiple notebooks and organization for the
> moment and first establish if you can write, or have written, some of the
> routines that do the things you want. If you can do that, you can simply
> put
> them in a Routines section in a notebook and evaluate the section when you
> open the notebook. You could make the Routines section an Initialization
> section so that it would automatically be evaluated when the notebook is
> opened, or when you first try to evaluate some other statement. Do you know
> how to organize a notebook into sections? You should use multiple sections
> in one notebook before going to multiple notebooks.
>
> When you get routines that work within the notebook (and there is no reason
> you shouldn't be able to do that) then you can consider moving them to a
> package. Do you write usage messages for your routines? If you have done
> these things, then it is VERY simple to move them to a package. But you
> have
> to get developed and tested routines first.
>
> I just get the feeling that you are getting bogged down in trying to
> redesign how Mathematica works and trying to provide an interface and
> organization that is already much better provided by its standard usage.
>
> First things first and these are to make sure you understand basic syntax
> and usage and then develop some of your first routines in a single
> organized
> notebook.
>
>
> David Park
> djmpark at comcast.net
> http://home.comcast.net/~djmpark/
>
>
> From: Paul [mailto:pkshreeman at gmail.com]
>
> On Jan 21, 6:33 am, Yves Klett <yves.kl... at googlemail.com> wrote:
> > Hi,
> >
> > packages (.m) might be very useful in your case. Since Version 6
> > .m-files are handled nicely in the fronted. There is no end of threads
> > covering the use of packages.
> >
> > Regards,
> > Yves
> >
> > Paul schrieb:
> >
> >
> >
> > > My fellow Mathematica'ians...
> >
> > > I am having difficult time figuring out whether it's my programming or
> > > the bugs:... I have first notebook called xy.nb that simply has
> >
> > > y=x+3
> >
> > > and then I have another notebook that has the following:
> >
> > > test=NotebookOpen[xy.nb];
> > > NotebookRead[test];
> > > x=7;
> > > SelectionMove[test,All,Notebook];   (*Seems I have to force selection=
> ,
> > > even though there's only one cell in the entire notebook xy.nb?*)
> > > SelectionEvaluate[test];
> > > Print["y equals to ",y]
> >
> > > Naturally, I'd expect the output to read, "y equals to 10" but the
> > > output is "y equals to y"...the variable "y" remains unevaluated or
> > > unassigned.  If I re-evaluate the y (either redoing the whole thing
> > > with kernel still running, or manually calling variable "y" by typing
> > > in frontend, "y" and hitting shift-enter.
> >
> > > This is simple example of my project, I wanted to develop a modular-
> > > style programming instead of really long single notebook to do my
> > > Dissertation work..and be able to call certain functions in separate
> > > notebooks (optional mathematical calculations, for instance)..and keep
> > > all global variables intact to be used in all calculations (AND be
> > > immediately usable once evaluated!).  Right now, I can't call xy.nb t=
> o
> > > do calculations, and take the value of "y" to do another type of
> > > calcuation since the value of "y" remains unassigned.
> >
> > > Thank you!
>
> Thank you for your reply.  Unfortunately, the creation of the package
> doesn't help either.  I use Mathematica 5...and I have tried using
> DumpSolve, Put/Get files, etc...the problem is that the notebook that
> I "call" has complex functions, including IF statements, Loops,
> etc...and the package (m.) doesn't seem to be able to generate correct
> IF statements.  What I needed is the ability to call up on named
> notebook (file/package/whatever) that can do this full calculations
> (including the necessary logistics) then immeditately give me the
> solution to apply immeditately.  The NotebookGet/EvaluateSelected only
> works if I complete the sequence and then manually type in request for
> the solution...for instance if I type "Print["Y equals to", y]
> manually after I completed the call evaluation cell, the results are
> correct.  I need it to be automatic.
>
>
>


  • Prev by Date: Re: Finding and changing strings in a matrix
  • Next by Date: Re: The formula of Abraham Moivre
  • Previous by thread: Re: Re: NotebookGet/Read/EvaluateSelection Issues
  • Next by thread: Re: NotebookGet/Read/EvaluateSelection Issues