MATLAB IN FOOD INDUSTRY

MATLAB - matrix library 

high performance language for technical computing

MATLAB allows-

* Matrix manipulation

*Plotting of functions & data

*Implementation of algorithms

*Creation of user interface

• it is a software package for computation & 

Visualization

• you can plot 2D & 3D graphics

•you can write your functions

• Basic building block of MATLAB  is 'matrix' 

• MATLAB was originally written to Provide

Easy access to matrix software developed by the LINPACK & EISPACK projects which together represent the state of the art & software for matrix  compulation

• MATLAB features a family of  application 

Specific to solution called toolbox. 

Toolbox :  comprehensive collection of MATLAB function (M- file ) that extend the MATLAB environment to solve particular class of problems 

Main 5 parts of MATLAB system  are - 

1. MATLAB language

* High level matrix/array language with control flow measurement , input output

Function & object oriented programming features 

*It allows both •programming in the large

                             •programming in the small

2. Working environment

*  Involes the  set of tools & facilities that 

You work in the MATLAB programmer 

*It includes tools for developing ,managing 

Debugging, profiling m-files , MATLAB applications 

*It includes facilities for the management 

Of variables in your workplace & import  & export of data 

3. API-

 library that allows you to write C &

Fotone  programs  that can interact with MATLAB, includes facilities for calling 

Routines from MATLAB ( dynamics linking)

Calling MATLAB as computational 

4.handle graphics- MATLAB graphic system 

Includes high level commands & law level commands 

•high level commands: for 3D & 2D data acquisition, image processing, animation & presentation graphics 

•law level commands: it allows you to customise the operation as well as build output GUI or your MATLAB applications 

5. Library: vast collection of computational 

Algorithms ranging from elementary functions like SUM,SIGN,etc. 

      Application in food industry


1. Some functions of MATLAB like simulink

Do well in stimulating production control,

Quality assessment, forecasting & other aspects while dealing with non-linear & non-stable processing 

2. MATLAB was introduced & it application in grading, production control. 


Script Files and the Editor/Debugger


You can perform operations in MATLAB in two ways:

1. In the interactive mode, in which all commands are entered directly in the Command window.

2. By running a MATLAB program stored in script le. This type of lecontains MATLAB commands, so running it is equivalent to typing all the commands, one at a time, at the Command window prompt. You can run the le by typing its name at the Command window prompt.


MATLAB uses two types of M- les: script les and function les. You can use the Editor/Debugger built into MATLAB to create M- les. Because they contain commands, script les are sometimes called command les.

Creating and Using a Script File


The symbol % designates a comment, which is not executed by MATLAB. Com-ments are used mainly in script les for the purpose of documenting the le. The comment symbol may be put anywhere in the line. MATLAB ignores everything to the right of the % symbol. For example, consider the following session.

>>% This is a comment.

>>x = 2+3 % So is this.

x =

5

Note that the portion of the line before the % sign is executed to compute x. 

Effective  Use of Script Files 

Create script les to avoid the need to retype lengthy and commonly used proce-dures. Here are some other things to keep in mind when using script les:

1. The name of a script le must follow the MA TLAB convention for naming variables.

2. Recall that typing a variable’s name at the Command window prompt causes MATLAB to display the value of that variable. Thus, do not give a script le the same name as a variable it computes because MATLAB will not be able to execute that script le more than once, unless you clear the variable.

3 .Do not give a script le the same name as a MA TLAB command or function.You can check to see if a command, function, or le name already exists by using the exist command. For example, to see if a variable example1 already exists, type exist(‘example1’); this will return a 0 if the variable does not exist and a 1 if it does. To see if an M- le example 1.m already exists, type exist(‘example 1.m’,’ le’) before creating the le; this will return a 0 if the le does not exist and a 2 if it does. Finally ,to see if a built-in function example1 already exists, type exist(‘example1’, ‘builtin’) before creating the le; this will return a 0 if the built-in function does not exist and a 5 if it does.

Note that not all functions supplied with MATLAB are built-in functions.

For example, the function mean.m is supplied but is not a built-in function. Thecommand exist(‘mean.m’, ‘ le’) will return a 2, but the command exist(‘mean’, ‘builtin’) will return a 0. You may think of built-in functions as primitives that form the basis for other MATLAB functions. You can-not view the entire le of a built-in function in a text editor , only the comments.

Debugging Script Files

Debugging a program is the process of nding and removing the “bugs,” or errors,in a program. Such errors usually fall into one of the following categories.

1. Syntax errors such as omitting a parenthesis or comma, or spelling a com-mand name incorrectly. MATLAB usually detects the more obvious errors and displays a message describing the error and its location.

2. Errors due to an incorrect mathematical procedure, called runtime errors.They do not necessarily occur every time the program is executed; their occurrence often depends on the particular input data. A common example is division by zero.

Cell Arrays

The cell array is an array in which each element is a bin, or cell, which can con-tain an array. You can store different classes of arrays in a cell array, and you can group data sets that are related but have different dimensions. You access cell arrays using the same indexing operations used with ordinary arrays.This is the only section in the text that uses cell arrays. Coverage of this sec-tion is therefore optional. Some more advanced MATLAB applications, such as those found in some of the toolboxes, do use cell arrays.
Creating Cell Arrays
You can create a cell array by using assignment statements or by using the cell function. You can assign data to the cells by using either cell indexing or content indexing. To use cell indexing, enclose in parentheses the cell sub-scripts on the left side of the assignment statement and use the standard array notation. Enclose the cell contents on the right side of the assignment statement in braces {}.
Suppose you want to create a 2  2 cell array A, whose cells contain the location, the date, the air temperature (measured at 8 A.M., 12 noon, and 5 P.M.), and the water tem-peratures measured at the same time in three different points in a pond. The cell array
looks like the following.


■ Solution
You can create this array by typing the following either in interactive mode or in a script  le and running it.
A(1,1) = {‘Walden Pond’};
A(1,2) = {‘June 13, 1997’};
A(2,1) = {[60,72,65]};
A(2,2) = {[55,57,56;54,56,55;52,55,53]};
If you do not yet have contents for a particular cell, you can type a pair of empty
braces { } to denote an empty cell, just as a pair of empty brackets [] denotes an empty
numeric array. This notation creates the cell but does not store any contents in it.

Structure Arrays
Structure arrays are composed of structures. This class of arrays enables you to store dissimilar arrays together. The elements in structures are accessed using named elds. This feature distinguishes them from cell arrays, which areaccessed using the standard array indexing operations.Structure arrays are used in this text only in this section. Some MATLAB toolboxes do use structure arrays.A speci c example is the best way to introduce the terminology of structures.Suppose you want to create a database of students in a course, and you want to in-clude each student’s name, Social Security number, email address, and test scores.Figure  shows a diagram of this data structure. Each type of data (name,Social Security number, and so on) is a eld, and its name is the eld name. Thus our database has four elds. The rst three elds each contain a text string, while he last eld (the test scores) contains a vector having numerical elements. A struc-ture consists of all this information for a single student. A structure array is an array of such structures for different students.

 



xy Plotting Functions


The “anatomy” and nomenclature of a typical xy plot is shown in Figure ,In which the plot of a data set and a curve generated from an equation appear. A plot can be made from measured data or from an equation. When data are plot-ted, each data point is plotted with a data symbol, or point marker, such as the small circles shown in Figure 5.1–1. An exception to this rule would be when there are so many data points that the symbols would be too densely packed.


that case, the data points should be plotted with a dot. However, when the plot
is generated from a function, data symbols must never be used! Lines between
closely spaced points are always used to plot a function.
The MATLAB basic xy plotting function is plot(x,y) as we saw in Chapter 1. If x and y are vectors, a single curve is plotted with the x values on the abscissa and the y values on the ordinate. The xlabel and ylabel com-mands put labels on the abscissa and the ordinate, respectively. The syntax is xlabel(‘text’), where text is the text of the label. Note that you must enclose the label’s text in single quotes. The syntax for ylabel is the same.The title command puts a title at the top of the plot. Its syntax is title(‘text’), where text is the title’s text.
The plot(x,y) function in MATLAB automatically selects a tick-mark spacing for each axis and places appropriate tick labels. This feature is called autoscaling. MATLAB also chooses limits for the x and y axes. The order of the xlabel, ylabel, and title commands does not matter, but we must place them after the plot command, either on separate lines using ellipses or on the same line separated by commas.

After the plot command is executed, the plot will appear in the Figure window. You can obtain a hard copy of the plot in one of several ways:

1. Use the menu system. Select Print on the File menu in the Figure window.Answer OK when you are prompted to continue the printing process.

2. Type print at the command line. This command sends the current plotd directlyto the printer.

3. Save the plot to a le to be printed later or imported into another applica-tion such as a word processor. You need to know something about graphics le formats to use this le properly 

Toolboxes use in MATALAB


Curve fitting toolbox-

•allows you to develop custom linear & non-linear models in graphics user interface 

•calculs fits & residuals confidence first derivative & integral of the fit 

Neural network toolbox 

•GUI for creating , training, & simulating 

Neural networks 

•it has support for the most commonly used supervised 

Optimization toolbox 

•includes standard algorithms for optimization

•including minimax ,goal attainment & semi infinite minimization problems 

Statistics toolbox 

•contains about 250 functions & GUI for:

 Generating random members , probability 

Distribution, hypothesis testing , statistical

 Plots & covers basic statistical functionality


Signal processing toolbox 

•an environment for signal analysis waveform generation , statistical signal processing & spectral analysis

•useful for designing features in conjunction with the image processing toolbox 











Post a Comment

0 Comments