how do i save the data from ginput?

This is my script:
% --- Executes on button press in pushbutton5. select finish line function pushbutton5_Callback(hObject, eventdata, handles)
data=[] data(1)=ginput(1); x=data(1){:,1} y=data(1){:,2}
i want to save the x, y points from the ginput, how would i do this?

Respuestas (1)

Dishant Arora
Dishant Arora el 13 de Mayo de 2014
data = ginput(2);
x = data(:,1);
y = data(:,2);
Or simply:
[x , y] = ginput(2);

5 comentarios

Franchesca
Franchesca el 13 de Mayo de 2014
Editada: Franchesca el 13 de Mayo de 2014
I receive this error:
Attempted to access data(:,1); index out of bounds because size(data)=[0,0].
Error in sprintfinish>pushbutton2_Callback (line 101) x = data(:,1);
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in sprintfinish (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)sprintfinish('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Franchesca
Franchesca el 13 de Mayo de 2014
okay it now works however, I cannot refer to it later on in the code it says undefined variable function 'x'
Undefined function or variable 'x'.
Error in sprintfinish>pushbutton3_Callback (line 117) st=x
"later in the code" , does that mean you want to use it other callbacks, if yes you need to store it in the handles structure:
data = ginput(2);
handles.data = data;
guidata(hobject , handles)
Franchesca
Franchesca el 13 de Mayo de 2014
okay so how would I refer to it later on?
data = handles.data;

Iniciar sesión para comentar.

Categorías

Más información sobre Data Exploration en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 13 de Mayo de 2014

Comentada:

el 13 de Mayo de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by