of 34

• date post

04-Jan-2016
• Category

## Documents

• view

41

3

Embed Size (px)

description

Εισαγωγή στην Επιστήμη των Η/Υ ΙΙ Μάθημα 6 Παλινδρόμηση – Δημιουργία Video - Συναρτήσεις - GUI. http://seismo.geology.upatras.gr/comp/. Προσαρμογή δεδομένων (curve fitting). Παλινδρόμηση (Regression). Μέθοδος των ελαχίστων τετραγώνων. Υ. Εξαρτημένη μεταβλητή. Χ. - PowerPoint PPT Presentation

### Transcript of Εισαγωγή στην...

• /

6

Video - - GUIhttp://seismo.geology.upatras.gr/comp/

• (curve fitting)

• (Regression)

• (Regression)

• Regression MatlabPolyfit p = polyfit(x,y,n), x,y p n

• Regression Matlabx = (0: 0.1: 2.5)';y = erf(x); p = polyfit(x,y,6)

p = 0.0084 -0.0983 0.4217 -0.7435 0.1471 1.1064 0.0004

• Regression Matlaby = polyval (p , x) X.: p : X f = polyval(p,x); p = polyfit(x,y,6)plot(x,y,'o',x,f,'-')

• Matlab

• Matlab

• Matlab moviein(n) - ( )

getframe -

movie

movie2avi AVI

mpgwrite MPEG

• MatlabF = getframeF = getframe(h)F = getframe(h,rect), [left bottom width height]

for j = 1:n plotting commands F(j) = getframe;End

movie(F)getframe -

• MatlabZ = peaks; surf(Z)axis tightset(gca,'nextplot','replacechildren');

for j = 1:20 surf(sin(2*pi*j/20)*Z,Z) F(j) = getframe;end

movie(F,20)

movie2avi(F,'test.avi)

• Matlabmovie(M)movie(M,n)movie(M,n,fps )movie(h,...)movie(h,M,n,fps,loc)movie - M , getframen * n : [ ]

.. movie(M,[13 1 2 3 4 5 4 3 2 1]) NumberofPlays = 2;FrameOrder = [1:5 4:-1:2]; movie(M,[NumberofPlays FrameOrder])

• Matlabmovie2avi(mov,filename)movie2avi(mov,filename,param,value,param,value...) movie2avi AVImov Matlab ( )

• (function) Matlab

• (function) Matlab

script

(function m-files) , function . Matlab.

script function editor ( editor Matlab - edit)H Matlab .m, M-files script files function files.

• (function) Matlab script

• (function) Matlab function Matlab,

,

1. (header) : function [output1, output2, .] = filename (input1, input2, .)

To filename .m function . . . function [out1] = parad(x, y) function out1 = parad(x, y)

2. (comments) % (). help function.

3. Matlab output.

• (function) Matlab function y = randint(m,n,a,b) % RANDINT Randomly generated integral matrix. % randint(m,n) returns an m-by-n such matrix with % entries between 0 and 9. % randint(m,n,a,b) returns entries between integers a and b. if nargin < 3, a=0; b=9; end y = floor((b-a+1)*rand(m,n))+a; randint.m.

• MATLAB, max, size, function m-files. function :

( ). , (underscore). MATLAB (.. ). . (function) Matlab

• (function) Matlabfunction [mean, stdev] = stat(x) % STAT Mean and standard deviation % For a vector x, stat(x) returns the % mean and standard deviation of x. % For a matrix x, stat(x) returns two row % vectors containing, respectively, the % mean and standard deviation of each column. [m n] = size(x); if m == 1 m = n; % handle case of a row vector end mean = sum(x)/m; stdev = sqrt(sum(x.^2)/m -mean.^2);

• GUI Matlab

• Graphical User InterfacesGUI , GUI.

menus, toolbars, push buttons, radio buttons, listboxes, and sliders . GUI Matlab

• GUI GUIDETo guide GUI Matlab. guide GUI .

guide :

*.fig GUI

*.m

• GUI guide guide edit ( callback),

• GUI

• GUI -

• GUI - callback

callback M-file GUI callback (e.g. CreateFnc, ButtonDwnFnc,Callback, DeleteFnc)

callback :1. 2. 3. /4. 5.

• GUI - % Create the data to plot.handles.peaks=peaks(35);handles.membrane=membrane;[x,y] = meshgrid(-8:.5:8);r = sqrt(x.^2+y.^2) + eps;sinc = sin(r)./r;handles.sinc = sinc;% Set the current data value.handles.current_data = handles.peaks;surf(handles.current_data)

• % Display surf plot of the currently selected data.surf(handles.current_data);

• % Determine the selected data set.str = get(hObject, 'String');val = get(hObject,'Value');% Set current data to the selected data set.switch str{val}; case 'Peaks' % User selects peaks. handles.current_data = handles.peaks; case 'Membrane' % User selects membrane. handles.current_data = handles.membrane; case 'Sinc' % User selects sinc. handles.current_data = handles.sinc;end% Save the handles structure.guidata(hObject,handles)

• GUI

• [FileName,PathName] = uigetfile('*.m','Select the M-file');helpdlg('Choose 10 points from the figure','Point Selection');prompt = {'Enter matrix size:','Enter colormap name:'};dlg_title = 'Input for peaks function';num_lines= 1;def = {'20','hsv'};answer = inputdlg(prompt,dlg_title,num_lines,def);

• *