how to export figure data into a .mat file

6 次查看(过去 30 天)
X=[0:.1:10];
Y=rand(length(X));
plot(X,Y)
is there a way to add a menu item to the figure window to save data (X,Y) into a file (have the user specify file name and location when they click on this menu item)

采纳的回答

Walter Roberson
Walter Roberson 2012-6-6
You can use uicontextmenu() to create a context menu, and you can set that to be the UiContextMenu property of an object such as an axes (and of anything else on the axes that you want to be independently clickable for other reasons, as context menus are sensitive to context)
Probably more often one would create a uicontrol('style','pushbutton') to do the work.
Use uiputfile() to have the user select a suitable output file.

更多回答(1 个)

Thomas
Thomas 2012-6-6
In the figure gui click..
File>Save Workspace As..>'Any filename'
  1 个评论
A
A 2012-6-6
the figure is generated within a function so it does not exist in the workspace

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by