醉資心最近掛了,害我無法查我以前紀錄下來的 matlab 常用功能,只好也在blog備份一篇。
How can I select multiple points using the Data Cursor and export the coordinates to the MATLAB workspace?
來源: mathworks , datacursormode
steps -
- plot the figure
- click the Data Cursor button on the toolbar
- click any point of your choice on the figure. if you wanna set multiple points, press Alt key.
- right-click anywhere on the figure –> “export cursor data to workspace” –> enter variable name –> enter
他會將cursor data存成structure,每個element有三個欄位。
- Target : 這筆cursor來自哪個figure (handle)
- Position: 座標
- DataIndex: 這筆cursor位於每個陣列的哪個位置
程式自動化的作法:
fig = figure;
z = peaks;
plot(z(:,30:35))
dcm_obj = datacursormode(fig);
set(dcm_obj,'DisplayStyle','datatip',...
'SnapToDataVertex','off','Enable','on')
% Now, click on the line to place datatip before executing the next line of code.
c_info = getCursorInfo(dcm_obj)

0 意見:
張貼意見