声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1988|回复: 4

[图像处理] 如何使得两个图像中的某一个具有datacursormode功能

[复制链接]
发表于 2007-12-28 01:31 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
我做了一个简单的GUI
里面有两个图像, 一个图像的名称是graphic, 另一个是circuit
我只要在graphic的图像有datacursormode的功能, 要怎样写那指令?

datacursormode on 这个是开启全部图像的  不是我要的
我看MATLAB本身的教学  只说datacursormode(figure_handle,...)
根本没有例子可以参考帮忙

希望大家能帮帮忙

[ 本帖最后由 ChaChing 于 2010-8-15 10:06 编辑 ]
回复
分享到:

使用道具 举报

发表于 2007-12-28 09:25 | 显示全部楼层
  1. hf1 = figure(1); hf2 = figure(2);
  2. datacursormode(hf1,...);
复制代码
试试吧

[ 本帖最后由 ChaChing 于 2010-8-15 10:09 编辑 ]

评分

1

查看全部评分

 楼主| 发表于 2007-12-28 10:04 | 显示全部楼层
这个和我在MATLAB里面找到的一样
datacursormode(hf1,...)   
那  ...  里面要放什么哦?

[ 本帖最后由 swn525 于 2007-12-28 10:29 编辑 ]
发表于 2007-12-28 10:52 | 显示全部楼层

回复 #3 swn525 的帖子

datacursormode
Enable or disable interactive data cursor mode
GUI Alternatives
Use the Data Cursor tool   to label x, y, and z values on graphs and surfaces. For details, see Data Cursor
— Displaying Data Values Interactively in the MATLAB Graphics documentation.

      Syntax
   datacursormode on
datacursormode off
datacursormode
datacursormode(figure_handle,...)
dcm_obj = datacursormode(figure_handle)
Description
datacursormode on enables data cursor mode on the current figure.
datacursormode off disables data cursor mode on the current figure.
datacursormode toggles data cursor mode on the current figure.
datacursormode(figure_handle,...) enables or disables data cursor mode on the specified figure.
dcm_obj = datacursormode(figure_handle) returns the figure's data cursor mode object, which enables you to customize the data
cursor. See Data Cursor Mode Object.
Data Cursor Mode ObjectThe data cursor mode object has properties that enable you to controls certain aspects of the data cursor.
You can use the set and get commands and the returned object (dcm_obj in the above syntax) to set and query property values.
Data Cursor Mode Properties
Enable
on | off
Specifies whether this mode is currently enabled on the figure.
SnapToDataVertex
on | off
Specifies whether the data cursor snaps to the nearest data value or is located at the actual pointer position.
DisplayStyle
datatip | window
Determines how the data is displayed.
     datatip displays cursor information in a yellow text box next to a marker indicating the actual data point being displayed.
     window displays cursor information in a floating window within the figure.
Updatefcn
function handle
This property references a function that customizes the text appearing in the data cursor.
The function handle must reference a function that has two implicit arguments (these arguments are automatically passed to the function by MATLAB when the function executes).
For example, the following function definition line uses the required arguments:
function output_txt = myfunction(obj,event_obj)
% obj                                Currently not used (empty)
% event_obj                                Handle to event object
% output_txt                                Data cursor text string (string or cell array of
%                                 strings).
event_obj is an object having the following read-only properties.Target — Handle of the object the data cursor is referencing (the object on which the user clicked).
Position — An array specifying the x, y,(and z for 3-D graphs) coordinates of the cursor.You can query these properties within your function.
For example,
pos = get(event_obj,'Position');
returns the coordinates of the cursor.See Function Handles for more information on creating a function handle.See Change Data Cursor Text for an example.
Data Cursor MethodYou can use the getCursorInfo function with the data cursor mode object (dcm_obj in the above syntax) to obtain information about the data cursor.
For example,
info_struct = getCursorInfo(dcm_obj);returns a vector of structures, one for each data cursor on the graph.
Each structure has the following fields:Target — The handle of the graphics object containing the data point.Position — An array specifying the x, y, (and z) coordinates of the cursor.
Line and lineseries objects have an additional field:DataIndex — A scalar index into the data arrays that correspond to the nearest data point. The value is the same for each array.ExamplesThis example creates a plot and enables data cursor mode from the command
line.surf(peaks)
datacursormode on
% Click mouse on surface to display data cursorSetting Data Cursor Mode OptionsThis example enables data cursor mode on the current figure and sets data cursor mode options. The following statementsCreate a graph Toggle data cursor mode to onSave the data cursor mode object to specify options and get the handle of the line to which the datatip is attached
fig = figure;
z = peaks;
plot(z(:,30:35))
dcm_obj = datacursormode(fig);
set(dcm_obj,'DisplayStyle','datatip',...
'SnapToDataVertex','off','Enable','on')


% Click on line to place datatip

c_info = getCursorInfo(dcm_obj);
set(c_info.Target,'LineWidth',2) % Make selected line wider Change Data Cursor TextThis example shows you how to customize the text that is displayed by the data cursor. Suppose you want to replace the text displayed in the datatip and data window with "Time:" and "Amplitude:" function doc_datacursormode
fig = figure;
a = -16; t = 0:60;
plot(t,sin(a*t))
dcm_obj = datacursormode(fig);
set(dcm_obj,'UpdateFcn',@myupdatefcn)


% Click on line to select data point

function txt = myupdatefcn(empt,event_obj)
pos = get(event_obj,'Position');
txt = {['Time: ',num2str(pos(1))],...
        ['Amplitude: ',num2str(pos(2))]};

[ 本帖最后由 sigma665 于 2007-12-28 11:02 编辑 ]

评分

1

查看全部评分

 楼主| 发表于 2007-12-28 11:58 | 显示全部楼层
谢谢sigma665 我知道怎么做了
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-23 17:17 , Processed in 0.071224 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表