SlideShare uma empresa Scribd logo
1 de 20
使用 Matlab GUI 建立簡單的
加法 器和創建卡的魔
術。
大網
 前言
 加法器
 卡的魔術
 結論
MATLAB (矩陣實驗室)是一個數值計算環境和
第四代編程語言。 第一 Matlab 軟件已經制定於
1984 年。在工程世界, MATLAB 是一個非常重
要的軟體,因為它可以:
•建立軟體
•創建應用程序
•解決數學函數
我們將建立一個簡單的加法器和創建一個卡的魔
術。
一 . 加法器
步驟
1.打開 MATLAB command: >> guide blank GUI
2.拖放 :
3.2 ‘edit text’ 按鈕 = inputs 輸入
equal sign 等號 (=)
1.2 ‘static text’ 按鈕
2. output 產量
3.1 ‘push button’ 按鈕 = sign 加號
雙擊每個元素 .
看此表上註明,並修改其屬性 .
Component HorizontalAlignment String Tag
Top Edit Text right 0 edit1
Bottom Edit Text right 0 edit2
Left Static Text center = text1
Rigth Static Text right 0 result
Push-button center + pushbutton1
 
function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version 
of MLB
% handles    structure with handles and user data (see 
GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 
as text
%        str2double(get(hObject,'String')) returns 
contents of 
%        edit1 as a double
num = str2double(get(hObject,'String'));
if isnan(num)
    num = 0;
    set(hObject,'String',num);
    errordlg('Input must be a number', 'Error')
end
handles.edit1 = num;
guidata(hObject,handles)
function edit2_Callback(hObject, eventdata, handles)
                          % hObject    handle to edit2 (see 
GCBO)
                          % eventdata  reserved - to be 
defined in a future version of MLB
                          % handles    structure with 
handles and user data (see GUIDATA)
                          % Hints: get(hObject,'String') 
returns contents of edit2 as text
                          %str2double(get(hObject,'String')) 
returns contents of 
                          %edit2 as a double
                          num = 
str2double(get(hObject,'String'));
                          if isnan(num)
                          num = 0;
                          set(hObject,'String',num);
                          errordlg('Input must be a 
number', 'Error')
                          end
                          handles.edit2 = num;
                          guidata(hObject,handles) 
--- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, 
eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a 
future version of MLB
% handles    structure with handles and user 
data (see GUIDATA)
addition = handles.edit1 + handles.edit2;
set(handles.result, 'String', addition);
 % --- Executes just before adder is made visible.
function adder_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MLB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to adder (see VARARGIN)
% Choose default command line output for adder
handles.output = hObject;
num = 0;
handles.edit1 = num;
handles.edit2 = num;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes adder wait for user response (see UIRESUME)
% uiwait(handles.figure1);
最後的結果是
二 . 卡的魔術 
我們現在要招 callback 功能要開發另一個電腦卡在
MatlabGUI 。
步驟
1.打開 MATLAB command: >> guide blank GUI
2.拖放 :
3.1 個 ‘ axes’ 按鈕
4. 1 個 ‘ static text ’ 按鈕
5.1 個 ‘ push button’ 按鈕
 雙擊每個元素 .
看此表上註明,並修改其屬性 .
Tag axes1 text1 pushbutton1
Position 4 6 75 22 84 15 23 8 83 6 22 2.5
FontSize 10 10
FontWeight bold bold
HorizontalAllignment left left
String
Choose a card
Don’t forget it!
Concentrate...
Continue...
• 現在你應該有類似此圖片
* 設置這些屬性存你的身材名稱為“ trick2.fig”.
* 編輯回調函數 callback-functions
* 編輯回調函數 callback-functions
 % --- Executes just before trick2 is made visible.
function trick2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to trick2 (see VARARGIN)
 % Choose default command line output for trick2
handles.output = hObject;
 clc
axes(handles.axes1);
bg = imread('trick2_001.jpg');
image(bg);
axis off;
 % Update handles structure
guidata(hObject, handles);
 % UIWAIT makes trick2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
 For the callback associated with the push-button, complete it like
this:
 % --- Executes on button press in pushbutton1.
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)
str = {'I see it clearly... ';
'';
'';
'I have made your card vanish!!'};
set(handles.text1,'String',str);
axes(handles.axes1);
bg = imread('trick2_002.jpg');
image(bg);
axis off;
 set(handles.pushbutton1,'Visible','off')
 最後,我們下載中心的圖像從這個網頁
http://www.matrixlab-examples.com/card-trick.html
運行文件“ trick2.m”
 點擊“繼續”按鈕,我們得到
結論
MATLAB 是一種非常有用的,非常強大的一個軟件。
 我們可以使用 MATLAB 的應用範圍,包括信號處理和通
信,圖像和視頻處理,控制系統,測試和測量,計算金
融學,計算生物學,機械和土木工程等 ...
但 matlab 的也有一些缺點。它使用了大量的內存和
較慢的計算機上。
references
 http://www.mathworks.com/products/matlab/
 http://www.matrixlab-examples.com/card-trick.html
 http://stackoverflow.com/questions/179904/what-is-matlab-good-for-why-is-it-so-used-by-u
 http://en.wikipedia.org/wiki/MATLAB
 http://www.mccormick.northwestern.edu/docs/efirst/matlab.pdf
 http://answers.yahoo.com/question/index?qid=20100605122719AAlCO8T
 http://www.ee.columbia.edu/~marios/matlab/matlab_tricks.html
 http://www.math.umd.edu/undergraduate/schol/matlab/description.html

Mais conteúdo relacionado

Destaque

Burj khalifa, the Highest building in the world
Burj khalifa, the Highest building in the worldBurj khalifa, the Highest building in the world
Burj khalifa, the Highest building in the worldAbdoul-Aziz Gansonre
 
BURKINA FASO- General presentation
BURKINA FASO- General presentationBURKINA FASO- General presentation
BURKINA FASO- General presentationAbdoul-Aziz Gansonre
 
Apache license
Apache licenseApache license
Apache license7410963
 
حديث الرحيل
حديث الرحيلحديث الرحيل
حديث الرحيل7410963
 
Multigenre Project
Multigenre ProjectMultigenre Project
Multigenre Projecthamboneeee
 
Introduction to burkina faso construction industry
Introduction to burkina faso construction industryIntroduction to burkina faso construction industry
Introduction to burkina faso construction industryAbdoul-Aziz Gansonre
 
A survey on modeling guidelines for quantity takeoff-oriented BIM-based design
A survey on modeling guidelines for quantity takeoff-oriented BIM-based designA survey on modeling guidelines for quantity takeoff-oriented BIM-based design
A survey on modeling guidelines for quantity takeoff-oriented BIM-based designAbdoul-Aziz Gansonre
 

Destaque (10)

Martin luther king BEST
Martin luther king BESTMartin luther king BEST
Martin luther king BEST
 
Burj khalifa, the Highest building in the world
Burj khalifa, the Highest building in the worldBurj khalifa, the Highest building in the world
Burj khalifa, the Highest building in the world
 
BURKINA FASO- General presentation
BURKINA FASO- General presentationBURKINA FASO- General presentation
BURKINA FASO- General presentation
 
Apache license
Apache licenseApache license
Apache license
 
حديث الرحيل
حديث الرحيلحديث الرحيل
حديث الرحيل
 
Multigenre Project
Multigenre ProjectMultigenre Project
Multigenre Project
 
Introduction to burkina faso construction industry
Introduction to burkina faso construction industryIntroduction to burkina faso construction industry
Introduction to burkina faso construction industry
 
A survey on modeling guidelines for quantity takeoff-oriented BIM-based design
A survey on modeling guidelines for quantity takeoff-oriented BIM-based designA survey on modeling guidelines for quantity takeoff-oriented BIM-based design
A survey on modeling guidelines for quantity takeoff-oriented BIM-based design
 
Bim and building life cycle
Bim and building life cycleBim and building life cycle
Bim and building life cycle
 
Johanna Moya winds
Johanna Moya windsJohanna Moya winds
Johanna Moya winds
 

Semelhante a An introduction to MATLAB

Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introductionideas2ignite
 
Digital Signal Processing
Digital Signal ProcessingDigital Signal Processing
Digital Signal ProcessingAssignmentpedia
 
intro_gui
intro_guiintro_gui
intro_guifilipb2
 
Raushan's MATLB PPT..pptx
Raushan's MATLB PPT..pptxRaushan's MATLB PPT..pptx
Raushan's MATLB PPT..pptxhmghj
 
426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer ToolsMark Billinghurst
 
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptxMATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptxprashantkumarchinama
 
From zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondFrom zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondMahuaPal6
 
Kevin merchantss
Kevin merchantssKevin merchantss
Kevin merchantssdharmesh69
 
KEVIN MERCHANT DOCUMENT
KEVIN MERCHANT DOCUMENTKEVIN MERCHANT DOCUMENT
KEVIN MERCHANT DOCUMENTtejas1235
 
Ppt 2 d ploting k10998
Ppt 2 d ploting k10998Ppt 2 d ploting k10998
Ppt 2 d ploting k10998Vinit Rajput
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systemsRaghav Shetty
 
Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab sessionDr. Krishna Mohbey
 

Semelhante a An introduction to MATLAB (20)

Matlab summary
Matlab summaryMatlab summary
Matlab summary
 
Matlab tut2
Matlab tut2Matlab tut2
Matlab tut2
 
Mmc manual
Mmc manualMmc manual
Mmc manual
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introduction
 
Digital Signal Processing
Digital Signal ProcessingDigital Signal Processing
Digital Signal Processing
 
intro_gui
intro_guiintro_gui
intro_gui
 
Raushan's MATLB PPT..pptx
Raushan's MATLB PPT..pptxRaushan's MATLB PPT..pptx
Raushan's MATLB PPT..pptx
 
426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools
 
Matlab anilkumar
Matlab  anilkumarMatlab  anilkumar
Matlab anilkumar
 
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptxMATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
From zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondFrom zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyond
 
Kevin merchantss
Kevin merchantssKevin merchantss
Kevin merchantss
 
KEVIN MERCHANT DOCUMENT
KEVIN MERCHANT DOCUMENTKEVIN MERCHANT DOCUMENT
KEVIN MERCHANT DOCUMENT
 
ESL report
ESL reportESL report
ESL report
 
Ppt 2 d ploting k10998
Ppt 2 d ploting k10998Ppt 2 d ploting k10998
Ppt 2 d ploting k10998
 
Tutorial2
Tutorial2Tutorial2
Tutorial2
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systems
 
ADVANCED WORKSHOP IN MATLAB
ADVANCED WORKSHOP IN MATLABADVANCED WORKSHOP IN MATLAB
ADVANCED WORKSHOP IN MATLAB
 
Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab session
 

Último

Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 

Último (20)

Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

An introduction to MATLAB