Using publish from within a GUI

Hello all,
This is my first time asking, so I hope I include everything needed. Presently I am trying to add a button to an existing GUI that creates an html data report and saves it using the publish command. I have been able to do this somewhat successfully, in that figures I have generated have saved to the appropriate areas and the folders are being created. The problem comes when trying to use 'opts.codeToEvaluate' to grab values that have been evaluated.
For example, suppose my function with markups and such is called test.m and it has an input called 'value'. Suppose also that I want to pass to it 'mu' to take the place of 'value'. Since 'mu' will change each time the button is pushed, I want to type in one command
opts.codeToEvaluate = 'value=mu; test(value)';
publish('test',opts);
If I do this, however, I get an "Error using evalin, the variable mu is not defined".
If more details or information is needed please let me know. I look forward to hearing some solutions. (I have thought of using the 'set' function, but not sure if it will work any better).
Ben

2 comentarios

Esben
Esben el 21 de Mzo. de 2012
Hey
I'm new to this publish funtion. It seems very simple when I have script file from which i want a report.
But I am currently working with a GUI and would really like to make a buttom that would generat a repport of say a figure and a value of a variable.
Could you give a hint on how to do that?
Kaustubha Govind
Kaustubha Govind el 22 de Mzo. de 2012
Esben: I think you should create a new question so more users will be notice it and might be able to help you out. Comments are not a good place to ask questions unless you are asking for clarification on what the poster said.

Iniciar sesión para comentar.

 Respuesta aceptada

Kaustubha Govind
Kaustubha Govind el 9 de Mayo de 2011

1 voto

My guess is that PUBLISH is looking for 'mu' in the base workspace instead of the GUI workspace. You could try creating 'mu' in the base workspace and see if that works:
assignin('base', 'mu', mu);

1 comentario

Ben
Ben el 9 de Mayo de 2011
Thank you very much, this solution worked perfectly. Now the GUI is auto-creating data files for an entire matrix of initial conditions. Have a good day.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Preguntada:

Ben
el 9 de Mayo de 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by