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 commentaires

Esben
Esben le 21 Mar 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 le 22 Mar 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.

Connectez-vous pour commenter.

 Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 9 Mai 2011

1 vote

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 commentaire

Ben
Ben le 9 Mai 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by