 Home
 Products
 Integration
 Tutorial
 Barcode FAQ
 Purchase
 Company
MATLAB Demysti ed in .NET
MATLAB Demysti ed Draw QR In Visual Studio .NET Using Barcode generation for VS .NET Control to generate, create QRCode image in .NET framework applications. QRCode Reader In VS .NET Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET applications. else new = []; end raw =[raw,new]; end
Bar Code Encoder In .NET Framework Using Barcode drawer for Visual Studio .NET Control to generate, create bar code image in .NET applications. Reading Barcode In .NET Framework Using Barcode decoder for VS .NET Control to read, scan read, scan image in VS .NET applications. What this loop does is it creates an array with individual elements repeated by frequency: Draw QR In C#.NET Using Barcode creator for VS .NET Control to generate, create QRCode image in VS .NET applications. Encode Quick Response Code In Visual Studio .NET Using Barcode printer for ASP.NET Control to generate, create QR Code JIS X 0510 image in ASP.NET applications. raw =
QR Code ISO/IEC18004 Creator In Visual Basic .NET Using Barcode creation for .NET Control to generate, create QR Code ISO/IEC18004 image in VS .NET applications. Barcode Encoder In .NET Framework Using Barcode encoder for VS .NET Control to generate, create barcode image in .NET framework applications. Columns 1 through 18
GS1  13 Creator In VS .NET Using Barcode generator for Visual Studio .NET Control to generate, create EAN13 image in .NET framework applications. Printing Linear 1D Barcode In .NET Framework Using Barcode generation for VS .NET Control to generate, create Linear 1D Barcode image in VS .NET applications. 17 28 28 17 31 18 31 21 33 21 34 21 34 24 37 26 28 28 Creating Code 3/9 In Visual Studio .NET Using Barcode maker for Visual Studio .NET Control to generate, create Code 39 Extended image in .NET framework applications. Encoding ISBN In .NET Framework Using Barcode generator for Visual Studio .NET Control to generate, create International Standard Book Number image in .NET applications. Columns 19 through 26
UCC  12 Decoder In Visual C#.NET Using Barcode scanner for .NET Control to read, scan read, scan image in .NET framework applications. Linear Creation In Visual Basic .NET Using Barcode creator for .NET framework Control to generate, create Linear 1D Barcode image in Visual Studio .NET applications. 37 37 39 40 40 43 43 43 EAN13 Scanner In None Using Barcode scanner for Software Control to read, scan read, scan image in Software applications. Code 39 Full ASCII Scanner In Visual C#.NET Using Barcode scanner for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications. So we have replaced the approach we used in the last section of having two arrays, one with the given age and one with the frequency at that age, by a single array that has each age repeated the given number of times We can use this raw data array with the builtin MATLAB functions to compute statistical information For example, the mean or average age of the employees is: Bar Code Drawer In Visual C# Using Barcode generation for .NET framework Control to generate, create bar code image in VS .NET applications. Making Code 128C In C# Using Barcode generation for Visual Studio .NET Control to generate, create ANSI/AIM Code 128 image in .NET framework applications. >> ave = mean(raw) ave = 307308
Drawing EAN13 Supplement 5 In VS .NET Using Barcode creator for Reporting Service Control to generate, create European Article Number 13 image in Reporting Service applications. Code 3 Of 9 Encoder In None Using Barcode generation for Font Control to generate, create Code 3 of 9 image in Font applications. We might also be interested in the median This tells us the age for which half the employees are younger, and half are older: >> md = median(raw) md = 31
The standard deviation is: >> sigma = std(raw) sigma = 83836
CHAPTER 4 Statistics/Intro to Programming
If the standard deviation is small, that means most of the data is near the mean value If it is large, then the data is more scattered Since our bin size is 1 year in this case, an 84 year standard deviation indicates the latter situation applies to this data Let s plot a scaled frequency bar chart to look at the shape of the data The rst step is to calculate the area of the data: area = binwidth*sum(f_abs); Now we scale it: scaled_data = f_abs/area; And generate a plot: bar(bins,scaled_data),xlabel('Age'),ylabel('Scaled Frequency') The result is shown in Figure 46 As you can see from the plot, the data doesn t t neatly around the mean, which is about 31 years For a contrast let s consider another of ce with a nice distribution Suppose that the employees range in age 17 34 with the following frequency distribution: f_abs = [2, 1, 0, 0, 5, 4, 6, 7, 8, 6, 4, 3, 2, 2, 1, 0, 0, 1]; 016 014 012 Scaled frequency 01 008 006 004 002 0 15
30 Age
Figure 46 Age data that has a large standard deviation
MATLAB Demysti ed
035 03 025 Scaled frequency 02 015 01 005 0 16
26 Age
Figure 47 A data set with a smaller standard deviation
If we go through the same process with this data, we get the scaled frequency bar chart shown in Figure 47 The basic statistical data for this set of employees is: >> mu = mean(raw) mu = 246538 >> med = median(raw) med = 25 >> sigma = std(raw) sigma = 33307
The standard deviation is much smaller and we can see it in the scaled frequency plot It is approaching the shape of a Gaussian or bell curve, which we show in Figure 48 CHAPTER 4 Statistics/Intro to Programming
exp( (x 25)2) 1 0 23 235 24 245 25 x 255 26 265 27 Figure 48 A bell curve with a mean of 25 years
When the data ts a Gaussian distribution, the standard deviation can be used to characterize the data to determine the probability of it falling at a certain value Let s just treat the last data set as if this were the case The standard deviation is denoted s while the mean is denoted by m Then the percentage of the graph that lies in the ranges: m  s x < m + s , m  2s x < m + 2s , and m  3s x m + 3s is 68%, 96%, and 997%, respectively Using the previous set of age data, the standard deviation and mean were found to be: sigma = 33307 >> mu mu = 246538
MATLAB Demysti ed
About 68% of the ages will be in 1 standard deviation of the mean, that is, between mu sigma = 213232 years and mu + sigma = 279845 years Going further, 96% of the ages will be between mu 2*sigma = 179925 years and mu + 2* sigma = 313152 years The correspondence is not exact, because our data set is not exactly a bell curve, but we are illustrating the idea and how you could use MATLAB to analyze data that is close to a bell curve More MATLAB Programming Tips
Earlier we wrote a script le (m) to implement a function which could be written up like computer code Let s digress a bit and round out the chapter looking at a few more programming structures First let s see how to get data from the user or from yourself in real time at a computer prompt This is done using the input function To use input, you set a variable you want to use to store the input data equal to the command, which takes a quotedelimited string as argument When the statement is executed MATLAB prints your string to the command window and waits for data to be typed in When the return key is hit, it assigns whatever data the user typed to the appropriate variable Let s concoct a simple example to see how this works Suppose that we want to get the number of square feet of a house, and given that the price of homes in Podunk, Maine is $10 per square foot, we output the total asking price of the house We can ask for and get the data using the following commands First, since we are working with nancial data here, we tell MATLAB to display results with the bank format Then we set our rate per square foot >> format bank >> rate = 10; Now let s ask the user to enter the square footage of the house by politely asking for it with the input command: >> sqft = input('Enter total sqft of house: ') MATLAB responds thus: Enter total sqft of house: If you enter these statements, MATLAB will be waiting patiently with a blinking cursor just to the right of this statement Let s say we enter 1740 The result is:

