SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Matlab: Procedures and Functions
Script files Script files, also called M- files as they have extension .m, make MATLAB programming much more efficient than entering individual commands at the command prompt. A script file consists of MATLAB commands that together perform a specific task. The M-file is a text file which can be created and edited by any plain text editor like Notepad, emacs or the built-in MATLAB editor. 
Script files Script files, also called M- files as they have extension .m, make MATLAB programming much more efficient than entering individual commands at the command prompt. A script file consists of MATLAB commands that together perform a specific task. The M-file is a text file which can be created and edited by any plain text editor like Notepad, emacs or the built-in MATLAB editor. 
Script files Here’s an example of what a script file looks like:
Script files Important commands: for- To print "Hello World" 10 times write ,[object Object]
disp('Hello World')
 end,[object Object]
a = b + 1
elseif a > b
 a = b - 1
else a = b
 end,[object Object]
 User Defined Functions An example of a function:
String Handling Creating strings Strings are matrices with character elements. The simplest way to create a string is to use it on the left side of an equal sign where the right side of the equal sign is an expression that evaluates to a string. String constants (literals) are enclosed in single quotes. The following example shows how to create string variables. >> first = 'John';  >> last = 'Coltrane';  >> name = [first,' ',last]
String Handling >> string='This is a string‘ >> string(3) % gives the third element in the variable words.  ans = i >> string(2)='t' % replaces the second element in the vector with t.
String Handling >> Y= input('Please type something here: ','s');  % Matlab expects a  number, string or a matrix from the keyboard.  % The second argument says the returned variable should be a string. >> disp('The name is: '), disp(x)  % gives text as output and the value of x.

Weitere Àhnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Coaxial feed microstrip patch antenna using HFSS
 Coaxial feed microstrip patch antenna using  HFSS Coaxial feed microstrip patch antenna using  HFSS
Coaxial feed microstrip patch antenna using HFSS
 
Unit1
Unit1Unit1
Unit1
 
Optical add drop multiplexer in Optical Fiber Communication
Optical add drop multiplexer in Optical Fiber CommunicationOptical add drop multiplexer in Optical Fiber Communication
Optical add drop multiplexer in Optical Fiber Communication
 
A seminar presentation on "Design and Simulation of E and U shape Microstrip ...
A seminar presentation on "Design and Simulation of E and U shape Microstrip ...A seminar presentation on "Design and Simulation of E and U shape Microstrip ...
A seminar presentation on "Design and Simulation of E and U shape Microstrip ...
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Adaptive filter
Adaptive filterAdaptive filter
Adaptive filter
 
Cdma
CdmaCdma
Cdma
 
Suppression of grating lobes
Suppression of grating lobesSuppression of grating lobes
Suppression of grating lobes
 
Adaptive Beamforming Algorithms
Adaptive Beamforming Algorithms Adaptive Beamforming Algorithms
Adaptive Beamforming Algorithms
 
Adaptive analog beamforming
Adaptive analog beamformingAdaptive analog beamforming
Adaptive analog beamforming
 
presentation on digital signal processing
presentation on digital signal processingpresentation on digital signal processing
presentation on digital signal processing
 
Antenna Measurements
Antenna MeasurementsAntenna Measurements
Antenna Measurements
 
microstrip antennae design & vhdl ppt
 microstrip antennae design & vhdl ppt microstrip antennae design & vhdl ppt
microstrip antennae design & vhdl ppt
 
Introduction to Digital Signal Processing
Introduction to Digital Signal ProcessingIntroduction to Digital Signal Processing
Introduction to Digital Signal Processing
 
Data and signals.ppt
Data and signals.pptData and signals.ppt
Data and signals.ppt
 
Mac protocols
Mac protocolsMac protocols
Mac protocols
 
MicroStrip Antenna
MicroStrip AntennaMicroStrip Antenna
MicroStrip Antenna
 
Am Radio Receiver And Amplifier Experiment And Am Transmission Demonstration
Am Radio Receiver And Amplifier Experiment And Am Transmission DemonstrationAm Radio Receiver And Amplifier Experiment And Am Transmission Demonstration
Am Radio Receiver And Amplifier Experiment And Am Transmission Demonstration
 
Dpcm ( Differential Pulse Code Modulation )
Dpcm ( Differential Pulse Code Modulation )Dpcm ( Differential Pulse Code Modulation )
Dpcm ( Differential Pulse Code Modulation )
 
Micaz and TelosB
Micaz and TelosBMicaz and TelosB
Micaz and TelosB
 

Andere mochten auch

How to work on Matlab.......
How to work on Matlab.......How to work on Matlab.......
How to work on Matlab.......
biinoida
 

Andere mochten auch (6)

Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introduction
 
Matlab assignment help
Matlab assignment helpMatlab assignment help
Matlab assignment help
 
MATLAB Scripts - Examples
MATLAB Scripts - ExamplesMATLAB Scripts - Examples
MATLAB Scripts - Examples
 
Introduction to Matlab Scripts
Introduction to Matlab ScriptsIntroduction to Matlab Scripts
Introduction to Matlab Scripts
 
Journal Club - Best Practices for Scientific Computing
Journal Club - Best Practices for Scientific ComputingJournal Club - Best Practices for Scientific Computing
Journal Club - Best Practices for Scientific Computing
 
How to work on Matlab.......
How to work on Matlab.......How to work on Matlab.......
How to work on Matlab.......
 

Ähnlich wie Matlab: Procedures And Functions

Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
Kurmendra Singh
 

Ähnlich wie Matlab: Procedures And Functions (20)

Matlab Basic Tutorial
Matlab Basic TutorialMatlab Basic Tutorial
Matlab Basic Tutorial
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab Manual
Matlab ManualMatlab Manual
Matlab Manual
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to Matlab
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
 
Matlab strings
Matlab stringsMatlab strings
Matlab strings
 
Pattern matching programs
Pattern matching programsPattern matching programs
Pattern matching programs
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Ch1
Ch1Ch1
Ch1
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotes
 
Ch09
Ch09Ch09
Ch09
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 
Matlab guide
Matlab guideMatlab guide
Matlab guide
 

Mehr von matlab Content

Mehr von matlab Content (20)

C,C++ In Matlab
C,C++ In MatlabC,C++ In Matlab
C,C++ In Matlab
 
Matlab: Control Statements
Matlab: Control StatementsMatlab: Control Statements
Matlab: Control Statements
 
Matlab: Discrete Linear Systems
Matlab: Discrete Linear SystemsMatlab: Discrete Linear Systems
Matlab: Discrete Linear Systems
 
Matlab Distributions
Matlab DistributionsMatlab Distributions
Matlab Distributions
 
Matlab: Graph Plots
Matlab: Graph PlotsMatlab: Graph Plots
Matlab: Graph Plots
 
Matlab: Gui
Matlab: GuiMatlab: Gui
Matlab: Gui
 
Matlab: Linear Methods, Quantiles
Matlab: Linear Methods, QuantilesMatlab: Linear Methods, Quantiles
Matlab: Linear Methods, Quantiles
 
Matlab Data And Statistics
Matlab Data And StatisticsMatlab Data And Statistics
Matlab Data And Statistics
 
Matlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge DetectionMatlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge Detection
 
Matlab Image Enhancement Techniques
Matlab Image Enhancement TechniquesMatlab Image Enhancement Techniques
Matlab Image Enhancement Techniques
 
Matlab Image Restoration Techniques
Matlab Image Restoration TechniquesMatlab Image Restoration Techniques
Matlab Image Restoration Techniques
 
Matlab Importing Data
Matlab Importing DataMatlab Importing Data
Matlab Importing Data
 
Matlab Organizing Data
Matlab Organizing DataMatlab Organizing Data
Matlab Organizing Data
 
Matlab Text Files
Matlab Text FilesMatlab Text Files
Matlab Text Files
 
Matlab Visualizing Data
Matlab Visualizing DataMatlab Visualizing Data
Matlab Visualizing Data
 
Matlab Working With Images
Matlab Working With ImagesMatlab Working With Images
Matlab Working With Images
 
Matlab: Non Linear Methods
Matlab: Non Linear MethodsMatlab: Non Linear Methods
Matlab: Non Linear Methods
 
Matlab: Programming Environment
Matlab: Programming EnvironmentMatlab: Programming Environment
Matlab: Programming Environment
 
Matlab: Regression
Matlab: RegressionMatlab: Regression
Matlab: Regression
 
Matlab: Saving And Publishing
Matlab: Saving And PublishingMatlab: Saving And Publishing
Matlab: Saving And Publishing
 

KĂŒrzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

KĂŒrzlich hochgeladen (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Matlab: Procedures And Functions

  • 2. Script files Script files, also called M- files as they have extension .m, make MATLAB programming much more efficient than entering individual commands at the command prompt. A script file consists of MATLAB commands that together perform a specific task. The M-file is a text file which can be created and edited by any plain text editor like Notepad, emacs or the built-in MATLAB editor. 
  • 3. Script files Script files, also called M- files as they have extension .m, make MATLAB programming much more efficient than entering individual commands at the command prompt. A script file consists of MATLAB commands that together perform a specific task. The M-file is a text file which can be created and edited by any plain text editor like Notepad, emacs or the built-in MATLAB editor. 
  • 4. Script files Here’s an example of what a script file looks like:
  • 5.
  • 7.
  • 8. a = b + 1
  • 10. a = b - 1
  • 12.
  • 13. User Defined Functions An example of a function:
  • 14. String Handling Creating strings Strings are matrices with character elements. The simplest way to create a string is to use it on the left side of an equal sign where the right side of the equal sign is an expression that evaluates to a string. String constants (literals) are enclosed in single quotes. The following example shows how to create string variables. >> first = 'John'; >> last = 'Coltrane'; >> name = [first,' ',last]
  • 15. String Handling >> string='This is a string‘ >> string(3) % gives the third element in the variable words. ans = i >> string(2)='t' % replaces the second element in the vector with t.
  • 16. String Handling >> Y= input('Please type something here: ','s'); % Matlab expects a number, string or a matrix from the keyboard. % The second argument says the returned variable should be a string. >> disp('The name is: '), disp(x) % gives text as output and the value of x.
  • 17. String Handling Also, different formats can be converted to ‘strings’ and vice verse. Here are some examples of functions that help in converting between different formats: int2str(n)  Converts an integer n to a string hex2num(hstr)  Converts hexadecimal number hstr to a float. hex2dec(hstr)  Converts hexadecimal string to decimal integer. dec2hex(n)  Converts decimal integer to hexadecimal string. bin2dec(str)  Converts binary string to decimal integer. mat2str(A,n)  Convert a 2-D matrix to a string in MATLAB syntax.
  • 18. String Handling There are several functions available to manipulate or fetch appropriate data from strings: blanks(n)  Gives a string with n blanks deblank(str)  Subtracts all blanks at the end of the string. lower(str)  All letters are changed to small. upper(str)  All letters are changed to capital. ischar(str)  If string contains character => gives 1 in return, 0 otherwise.
  • 19. String Handling There are several functions available to manipulate or fetch appropriate data from strings: isletter(str(i))  If element number i in the string is a letter=> gives one in return. isspace(str)  True for white space characters. strcmp(str1,str2)  returns 1 if strings S1 and S2 are the same and 0 otherwise. strcmpi(str1,str2)  returns 1 if strings S1 and S2 are the same except forcase and 0 otherwise.
  • 20. String Handling There are several functions available to manipulate or fetch appropriate data from strings: strfind(str1,str2)  returns the starting indices of any occurrences of the string str2 in the string str1. findstr(str1,str2)  returns the starting indices of any occurrences of the shorter of the two strings in the longer.
  • 21. Visit more self help tutorials Pick a tutorial of your choice and browse through it at your own pace. The tutorials section is free, self-guiding and will not involve any additional support. Visit us at www.dataminingtools.net