MATLAB PROGRAMMING

Matlab programming is very much useful to compute numerical calculations and support to simulate different kinds of concepts.  Matlab programming has numerous built-in commands and math functions. Matrix Laboratory is a fourth generation high-level programming language.

Uses of Matlab Programming:

  • Matlab programming is used to develop important concepts under image processing domain.
  • Several default matlab functions are used to perform critical algorithms presented in medical imaging.
  • Different image formats are accepted as input by matlab programming and produce accurate results.

Factors to be considered for Matlab Programming:

  • Scripts.
  • Control Flow.
  • Error Messages.
  • Debugging M Files.

 

Toolboxes Used in Matlab Programming:

  • Symbolic Toolbox.
  • Image Processing Toolbox.
  • MATLAB Compiler.
  • Legacy Toolboxes.

Syntax for Matlab Function:

function [y1,…,yN] = myfun(x1,…,xM)

Applications of Matlab Programming:

  • Medicine.
  • Computer graphics.
  • Pattern recognition.
  • Machine Learning.

 

Matlab Examples:

  • Filtering.
  • Controls.
  • Phase Vocoder.

 

 

Types of Matlab Functions:

  • Local Functions.
  • Nested Functions.
  • Base and Function Workspaces.
  • Function Precedence Order

Sample Code for Function with Multiple Outputs

Define a Function
function [m,s] = stat(x)
n = length(x);
m = sum(x)/n;
s = sqrt(sum((x-m).^2/n));
end

Call Function from Command Line:
values = [12.7, 45.4, 98.9, 26.6, 53.1];[ave,stdev] = stat(values)

Sample code for matlab programming:

function max = mymax(n1, n2, n3, n4, n5)
%This function calculates the maximum of the
% five numbers given as input
max = n1;
if(n2 > max)
max = n2;
end
if(n3 > max)
max = n3;
end