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 个评论

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?
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.

请先登录,再进行评论。

 采纳的回答

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 个评论

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.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by