카테고리 없음2013. 4. 3. 00:17

Syntax

filename = uigetfile
[FileName,PathName,FilterIndex] = uigetfile(FilterSpec)
[FileName,PathName,FilterIndex] = uigetfile(FilterSpec,DialogTitle)
[FileName,PathName,FilterIndex] = uigetfile(FilterSpec,DialogTitle,DefaultName)
[FileName,PathName,FilterIndex] = uigetfile(...,'MultiSelect',selectmode)

Description

filename = uigetfile displays a modal dialog box that lists files in the current folder and enables you to select or enter the name of a file. If the file name is valid and the file exists, uigetfile returns the file name as a string when you click Open. Otherwise uigetfile displays an appropriate error message, after which control returns to the dialog box. You can then enter another file name or click Cancel. If you click Cancel or close the dialog window, uigetfile returns 0.

 
Posted by 오늘보다 나은 내일
카테고리 없음2013. 4. 2. 20:47

function userDraw(handles)
%F=figure;
%setptr(F,'eraser'); %a custom cursor just for fun

A=handles.axesUserDraw; % axesUserDraw is tag of my axes
set(A,'buttondownfcn',@start_pencil)

function start_pencil(src,eventdata)
coords=get(src,'currentpoint'); %since this is the axes callback, src=gca
x=coords(1,1,1);
y=coords(1,2,1);

r=line(x, y, 'color', [0 .5 1], 'LineWidth', 2, 'hittest', 'off'); %turning     hittset off allows you to draw new lines that start on top of an existing line.
set(gcf,'windowbuttonmotionfcn',{@continue_pencil,r})
set(gcf,'windowbuttonupfcn',@done_pencil)

function continue_pencil(src,eventdata,r)
%Note: src is now the figure handle, not the axes, so we need to use gca.
coords=get(gca,'currentpoint'); %this updates every time i move the mouse
x=coords(1,1,1);
y=coords(1,2,1);
%get the line's existing coordinates and append the new ones.
lastx=get(r,'xdata');  
lasty=get(r,'ydata');
newx=[lastx x];
newy=[lasty y];
set(r,'xdata',newx,'ydata',newy);

function done_pencil(src,evendata)
%all this funciton does is turn the motion function off 
set(gcf,'windowbuttonmotionfcn','')
set(gcf,'windowbuttonupfcn','')
참고 : http://we15hang.blogspot.ca/2012/04/matlab-gui-interactive-drawing.html

Posted by 오늘보다 나은 내일
카테고리 없음2013. 3. 29. 21:06

xl=get(handles.axes1, 'xlim');          yl = get(handles.axes1, 'ylim');

 

 

Working on multislides form

 

 

first go to openingFcn callback and set all uipanel visibile to off except the 1st one which is uipanel1. Here it is just one panel uipanel2

 

function gui1_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% Choose default command line output for gui1

handles.output = hObject;

set(handles.uipanel2,'Visible','Off');

% Update handles structure

guidata(hObject, handles);

 

Now go to pushbutton1 (Next Button ) callback and set the uipanel1 visible to off and uipanel2 visible to on. That way when you click on next button, second one will appear and first will disappear. Remember you are just making it in invisible.. All the data which you have entered is as it were.. no harm to them. 

 

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.uipanel2,'Visible','On');

set(handles.uipanel1,'Visible','Off');

 

Do the same for pushbutton2 callback but other way around

 

function pushbutton2_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.uipanel1,'Visible','On');

set(handles.uipanel2,'Visible','Off');


 

Posted by 오늘보다 나은 내일