how to export figure data into a .mat file

조회 수: 8 (최근 30일)
A
A 2012년 6월 6일
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