Matlab - Ayuda con una de las líneas del código

 
Vista:

Ayuda con una de las líneas del código

Publicado por Jose (3 intervenciones) el 15/07/2011 00:10:47
Hola,

Estoy trabajando con la siguiente función:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% main function
function main_fcn

% create figure
hFigure = figure;
% make sure figure is drawn before properties are set
drawnow

% create a text box ui control to display mouse position
hText = uicontrol(hFigure, 'Style', 'text', ...
'BackgroundColor', [0 0 0], ...
'ForegroundColor', [1 1 1]);

% set properties of figure and define mouse motion callback function
set( hFigure, ...
'color', [0 0 0], ...
'menubar', 'none', ...
'toolbar', 'none', ...
'name', 'Graphics Output Window', ...
'numbertitle', 'off', ...
'pointer', 'crosshair', ...
'WindowButtonMotionFcn', {@hFigure_MotionFcn, hText});

% mouse motion callback function
function hFigure_MotionFcn(hFigure, event_data, hText)
% get position of mouse
mouse_pos = get(hFigure,'CurrentPoint');

set( hText, ...
'Position', [mouse_pos(1) mouse_pos(2) 100 20], ...
'String', ['x = ' num2str(mouse_pos(1)) ', y = ' num2str(mouse_pos(2))]);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Lo único que no entiendo : 'Position', [mouse_pos(1) mouse_pos(2) 100 20],

¿Por qué los números ''1'' y ''2'' después de cada mouse_position?

La propiedad 'Position' necesita de 4 entradas para quedar determinada. Las cordenadas (x,y), el ancho y la altura de la caja de texto.

¿ Por qué no basta con poner solamente : 'Position', [mouse_pos 100 20], ...

¿ No quedan establecidas las coordenadas (x,y) con la variable mouse_pos?

Espero haberme explicado bien.

Muchas Gracias,

Jose
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder