Site.iugaza.edu.ps



[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

How to build

[pic]

[pic]

[pic]

Layout Editor

[pic]

[pic]

[pic]

Components

[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

Example 1-clickme

[pic]

[pic]

Example 2 Factorial

1. Add PB edit text and static text controls

2. Change their properties: fontsize, font weight, string, tag, background color…..

(inactive, string, tag- look at code before and after change tags)

3. Activate (compile) ----- get myfactorial.fig and myfactorial.m and run version of the factorial -------------------------- does not do anything so far.

4. Add code needed

[pic]

Example 3 -MyCalculator

[pic]

Example 4 myplot - can write a user function for plotting

[pic]

[pic]

5-Money Convert

% --- Executes on selection change in lstFrom.

function lstFrom_Callback(hObject, eventdata, handles)

% hObject handle to lstFrom (see GCBO)

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

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

% Hints: contents = cellstr(get(hObject,'String')) returns lstFrom contents % % as cell array

% contents{get(hObject,'Value')} returns selected item from lstFrom

set(handles.edInput,'string','0.00');

set(handles.edOutput,'string','0.00');

function slEx_Callback(hObject, eventdata, handles)

% hObject handle to slEx (see GCBO)

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

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

% Hints: get(hObject,'Value') returns position of slider

% get(hObject,'Min') and get(hObject,'Max') to determine range of slider

n=get(hObject,'value');

set(handles.txtEx,'string',n);

function edInput_Callback(hObject, eventdata, handles)

% hObject handle to edInput (see GCBO)

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

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

% Hints: get(hObject,'String') returns contents of edInput as text

% str2double(get(hObject,'String')) returns contents of edInput as a double

exchR=str2double(get(handles.txtEx,'string'));

minput=str2double(get(hObject,'string'));

set(handles.edOutput,'string',exchR*minput);

6-Guessing Game

% --- Executes on button press in pbNew.

function pbNew_Callback(hObject, eventdata, handles)

% hObject handle to pbNew (see GCBO)

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

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

%%%tic

g=timerfind; stop(g); delete(g);

t1=timer;

h=handles.text1;

k=30+1;

set(handles.edTry,'string',0);

set(t1,'TimerFcn',@(x,y) set(h,'string',k-get(t1,'TasksExecuted')), ...

'Period', 1,'ExecutionMode','FixedSpacing','TasksToExecute',k);

start(t1)

set(hObject,'Enable','off');

RN=round(99*rand+1);

handles.t1=t1;

handles.RN=RN;

handles.fn=1;

guidata(hObject, handles);

function edTry_Callback(hObject, eventdata, handles)

% hObject handle to edTry (see GCBO)

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

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

% Hints: get(hObject,'String') returns contents of edTry as text

% str2double(get(hObject,'String')) returns contents of edTry as a uble

RN=handles.RN;

GN=str2num(get(hObject,'string'));

if handles.fn 0

if GN>RN

msgbox('Try a smaller number!');

elseif GN> deploytool (enter at command window)

[pic]

Enter name of project and then "OK"

Add *.m file as Main file; and *.fig file as shared resources

[pic]

[pic]

Then enter build, get

[pic]

When done, get

[pic]

Then click Close

Exit Matlab and go to "distrib" folder, and run Myfactorial.exe

Another way

From File menu Export GUI of myplot.fig into myplot-export.m

>> deploytool at command window

[pic]

Change name of project and location then OK, get

[pic]

Add file you exported; the click Build

[pic]

And

[pic]

Then click Close

Exit Matlab and go to "distrib folder"

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download