21552842 Mathcad Tutorial Introduction Examples CADDIT Australia

Embed Size (px)

Citation preview

CADDIT.net CADDIT Guide: Overview of Mathcad 14.0 basics & Industry Specific Features. 2009 CADDIT Pty Ltd, CAD and Design software partners Liverpool, NSW 1871. Visit us at www.caddit.net -1Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http://w ww.caddit.net/

Contents Mathcad - Exploring the possibilities........................................... .....................3 Mathcad Jack of all trades................................. ..........................................4 Using Mathcad Beginners Overview .... .........................................................6 Inserting Text, funct ions, values and changing the unit system ........................... 6 Errors a nd solution checking for calculations .......................................... ................ 7 Entering Characters and other functions using shortcuts...... ................................ 8 Graphing .................................... ................................................................................ .... 8 Integrating Mathcad with PTC Pro/Engineer ............................... .......................... 11 Mathcad Libraries and Extension Packs ............ ............................................13 Mathcad Engineering Libraries ... ............................................................................. 13 Mathcad Extension Packs ....................................................... ................................. 13 Industry Specific Examples ................ .............................................................14 Chemical Analysi s............................................................................... ....................... 14 Medical Imaging and Nuclear Medicine................. ................................................. 18 Preconditioning Data ...... ................................................................................ ........... 29 Descriptive Statistics........................................... ....................................................... 34 Index ............... ................................................................................ ...................39 -2Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http://w ww.caddit.net/

Mathcad - Exploring the possibilities Lets journey back to a time before all our fancy electronic gizmos and time savin g devices, to a time where maths was much simpler and counting was done simply w ith the use of our fingers or a tally stick. As record keeping methods and arith metic developed so did our use of tools such as the abacus particularly in parts of Asia and Africa. The abacus was in use centuries before we adopted the writt en modern numeral system. We have since then had many technological advances beginning with the invention of the calculator. Now imagine life without calculators, not only would calculat ions be much more difficult to compute but more advanced calculations would also occur at a snails pace. Think of the implications in fields such as mathematics , science, engineering, business, and aerospace just to name a few. There would have been obvious limitations placed on the growth and development within these fields. Further advances have since occurred in the field of software to help co pe with the very real and present demand for a mathematical program that allows users to perform, document, share calculations and design work. Mathcad was firs t introduced in 1986 and is the first and only engineering calculation software that automatically computes and documents engineering calculations while dramati cally reducing the risk of costly errors. Mathcad version 14.0 is now the global standard in engineering calculation. Mathcad is used by engineers, scientists and other technical professionals to ca pture knowledge reuse calculations and encourage collaboration. Its unique visua l format and easy to use scratchpad user interface (WYSIWYG) integrates standard mathematical notation, text and graphs in a single worksheet makes life simpler . Mathcad is superior to any proprietary calculating tool and spreadsheets in th at it allows you to document, format and present your work while simultaneously applying comprehensive mathematical functionality and dynamic, unit aware calcul ations. PTC have coined the term Engineering excellence however this ebook is aimed at loo king not only at the field of engineering but the other possibilities that exist for Mathcad in other industries including the medical and scientific fields. Ma thcad is not only easy to learn but easy to use and does not require additional programming skills or training required for its use. It is able to increase prod uctivity and improve verification and validation of calculations within a variet y of industries. Not only is it able to reuse calculation content saving time an d effort, Mathcad is able to securely manage calculations and ensure a significa nt reduction in errors. -3Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http://w ww.caddit.net/

Mathcad Jack of all trades Mathcad is a mathematical "Jack of all trades" application for visual calculatio ns in engineering, medicine, imaging, quality control, statistics, data analysis and transformation. Here are just a few examples of the fields for Mathcad appl ication. Concept Field Quality Control MathCAD module Data analysis Utilities and descriptive statistics Comments Quality control and quality engineering are used in developing systems to ensure products or services are designed and produced to meet or exceed custo mer requirements. It deals with assurance and failure testing in design and prod uction of products or services, to meet or exceed customer requirements. Therefo re it is an extremely important aspect in the manufacturing process and errors c an result in loss of productivity, time and money. Mathcad can help to accelerat ing products to market, reducing costs and eliminating the risk of design failur es. Chemical analysis Data analysis Preconditioning data and interpolation Chemical analysis deals with the central tasks of finding out the identity of an unknown substance, determining its properties and structure, isolating it from other components, and detecting it and quantifying its amount in a given system. e.g. Water analysis, metal detection, assay & purity testing, spectroscopy, tit ration, nuclear magnetic resonance. http://science.widener.edu/~svanbram/mathcad .html Civil and environmental Engineering Data analysis e.g. When comparing two different materials the Wilcoxon Signed-Rank Test can be used to find to some degree the statistical significance, whether the means of two different data sets are equal, i.e. if they came form the same distribution. Signal/ waveform preconditioning Data analysis Mean smoothing Cosine smoothing Many of todays applications require measuring, or creating a precise signal in a very noisy environment. This may require the use of smoothing filters however so me built-in filters tend to over-smooth data, removing important features. MathC AD allows for greater control in order to obtain the desired level of filtering required for a specific task. http://www.caddit.net/forum/viewtopic.php?p=771 ht tp://www.imakenews.com/ptcexpress/e_article001119634.cfm?x=bcR12Vy,b3jsqcsB,w Astronomy Data analysis Mathcad can also have applications in the field of astronomy. For example it can be used to generate a set of orbital elements for the planet a planet that can be used to calculate its position at any instant of the year. Orbital elements a re a dynamical astronomer s way of describing an orbit in a manner that is usefu l for calculating positions in the orbit E.g. Two-Point, Two-Body Elements for t he Planet Jupiter

Equipment calibration Data analysis Effective calibration and maintenance of equipment and measuring devices is an o ften overlooked, but critical component of an effective, long-term quality manag ement program. Mathcad helps improve the life and accuracy of equipment by imple menting reliable, effective calibration and maintenance processes. e.g. Calibrat ion of thermocouples -4Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http://w ww.caddit.net/

Medical imaging (Radiodiagnostics, electron microscopy, nuclear medicine) Imaging Processing & Wavelets Image processing and analysis can be used to clean images, remove distortions, h ighlight important features, add colour, image manipulation, manipulating colour , combining images, zoom, enlarge, making images crisper, create inverse images and much more. It is also a means of extracting quantitative information from im ages as well as a means of detecting and measuring objects in images. http://www .caddit.net/forum/viewtopic.php?t=243 Speech pathology Imaging Processing & Signal Processing The Speech spectrogram module along with the Fourier transformations module can be used in the area of Speech Pathology to analyse abnormal speech patterns. Forensics & Security Wavelets Fingerprint recognition or fingerprint authentication refers to the automated me thod of verifying a match between two human fingerprints. Wavelets are particula rly useful in compressing digitised fingerprints. Wavelet methods were selected as part of an FBI standard for compression of fingerprint images. http://www.afp .gov.au/national/e-crime/forensics.html -5Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http://w ww.caddit.net/

Using Mathcad Beginners Overview Heres a basic introduction to some of the tools and applications available in Mat hcad. Note: For help on installing Mathcad for the first time, click HERE. Now, as we start Mathcad software, a window as the one shown here should appear. On t his Image, each area of the window is labelled for your consideration as we walk through the workspace or window in which you will be working in. The drop menus are the list of menus in which you can find various commands to m ath, graphics symbolic options to use in Mathcad as well as the various function s of editing and controlling your worksheets that you will working with. The Ins ert, Format and Symbolics menus are the most commonly used drop menus to gain ac cess to the different mathematical function at your disposal with Mathcad. As we go down further in the image from the drop menus, there are list of icons where are all shortcuts various and commonly used functions in Mathcad. This is known as the main toolbar. Here you can save, cut, paste, change fonts and sizes and other various functions as well. Under the main toolbar is the math palette. Her e is a set of shortcut icons of just a few of the many functions that are with M athcad. Note to take is that by clicking on any of the icons in the math palette will open an additional dialogue box which will allow you to use the various op tions are made available to you. In addition to that, there is also a control pa lette that allows Object Linking and Embedding (OLE). This means that you can in tegrate various items from other programs to be added to your worksheet in the c alculation process. However it is required that you need to understand a degree of scripting before you undertake using this function. Next is the workspace in which will be doing the layout out of the calculations as well as various descri ptions and information to be placed in. At very bottom of it all there is a smal l section known as the message box. This box will tell you what description of t he function you have selected. Inserting Text, functions, values and changing the unit system In Mathcad, you have noticed that the position on workspace red crosshair. By se lecting a position on the worksheet you will be able to enter in values, text or an equation at that location. Simple arithmetic can be entered via the number p ad located on the right hand side of the -6Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http://w ww.caddit.net/

keyboard or using the calculator icon located in the math palette. By entering a n equal sign after the calculation, Mathcad will give a solution. By adding diff erent units in the previous equation by simply re-clicking the area in which the equation is entered, will allow for Mathcad to recalculate the answer in units for you. To change the units in the final answer, just simply double click the u nit and a dialogue will open up to allow you to select the various units which a re available in Mathcad. Depending on the version you have, the European version will have the units based on the SI system, however you can change to imperial system or US system by going to the drop menu> select tools > Worksheet options >select the Unit system tab and selecting the desired unit system. Mathcad also has a list of various functions which you can simply access by goin g to the drop menu > insert > function. This will open a dialogue as shown here, allowing you to access a large variety of functions which are used in mathemati cs, engineering and other fields requiring calculations. You can also move singu lar or multiple calculations on the workspace, by holding the left mouse button and dragging a box highlighting the calculations. You will notice that a hand wi ll appear over the box highlighted allowing you to move calculations freely in t he workspace. By using the Shift key, you can deselect various parts of the calc ulations that you do not want to move. Errors and solution checking for calculations Algebraic expressions can also be entered into Mathcad and then able to generate a solution with given values. Firstly, this is done by entering the expression, and then above it entering the values of the various terms show in the equation . Note that if the equation is showing some highlighted parts of the equation, t his tells the user that he or she has not entered the necessary values to work o ut the solution to the equation. Mathcad provides an answer to the highlighted e rror in the calculation by click on the error itself. A small description will b e given. Note to remember is when entering expressions use the colon key Shift+ [:] and when giving a value use For example, In the image below you can see what Mathcad has Identified a problem with my calculation of y here. I haven t given the value for b within the calculations and shown in the next image the problem is identified as soon as I clicked here: -7Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http://w ww.caddit.net/

Entering Characters and other functions using shortcuts A lot of the functions have been arranged into shortcut keys. Example of this is the Greek characters which are most commonly used in engineering equations and calculations. With Other programs such as excel will require for you to go to th e character maps and select the individual and then insert them into the field, cut and paste the expression into the desired equation. Mathcad has provided the shortcut within in the Math palette where you can add the characters individual ly or by pressing Ctrl and keystroke g to change the previous character entered into a Greek character. Example of this is the pi symbol. To create the characte r pi, you just have type the letter p and then ctrl+g to change it or alternativ ely use ctrl+shift+p to get the symbol of pi. This is only one example of the va rious keyboard shortcuts which can be found in drop menu help > quick sheets > k eyboard shortcuts. Graphing Graphing of various points can be done differently depending on the values which are used as well as the function which is used to generate the graph. Now by cr eating a table of values (done by right clicking within the workspace >insert ta ble), you can use this to define your graph. Firstly you will need to enter in t he values in the appropriate fields as shown in this example. Once you have comp leted this, the next step will require for you to define the table. In this case , we will define the table as T. Next we will have to define the X and Y axis in which values we will be 0 using. By typing x, : m [ctrl+6], 0, this will give t he following function of x:= m . This will tell Mathcad to use the values found in column 0 as the x -values. The process is repeated to the y 1 axis by replaci ng the x with y and 0 with 1 giving the function of y:= m . You can also sketch graphs based on data collected by using the matrix function as well to define the values given. This is done by entering the name of the dat a and then by pressing [Ctrl+M] to open the matrix option. Next define the amoun t of values which will be entered and enter the data required. For example: the values for X axis can be called xdata and pressing [shift+colon] and then [ctrl+ M] to generate the matrix. Next is just adjusting the amount of columns as well as rows for your data. In this example, we will be using only 1 column and 5 row s. Now we enter the vales for the x axis and then repeat the same steps for the y axis. -8Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http://w ww.caddit.net/

Once the values of the X and Y axis has been complete, either go to the drop men u insert and then graph and then X,Y plot or go to the Math palette, graph icon and then x, y plot icon. This will give you a graph which looks like the followi ng image: You will need now to define the X and Y axis by clicking on the Axis Label under the x axis and type x to set the X axis and repeat for the y axis in a similar fashion. Once you have done this, click outside the graph box to generate the gr aph. You can adjust the upper and lower limits of the x and y axis values by cli cking within the box and changing the values near to the limits of the axis as i ndicated here. The Graph can also be formatted based on preference of colour, st yle as well showing the gridlines on graph. This is accessed by right clicking o n the graph area and selecting the format option. Here you will gain additional dialogue were you can change the format of the graph to better present the value s to your liking. Going back to the insert text option, various points of the graph can also be la belled and information can be given specific area of the graph. This can be perf ormed by using the insert text function outside of the graph and then selecting the text or label and placing it on the graph as desired. This is another functi on which allows for the Mathcad user to perform simple and easy task of labellin g the graphs properly to share views and ideas other people who are looking thro ugh the calculation. -9Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http://w ww.caddit.net/

Multiple algebraic expressions of various graphs can be placed all on a singular graph to compare the differences between functions drawn up. This can be done b y entering multiple algebraic by the y axis and ensuring that the expressions ar e still using the same x values. For example as shown here, we can see that the all the expressions which are used here are labelled different yet still use the same variable (x). Note: When entering in the functions, ensure that the functi ons used are separated by commas. For example: f(x),c(x),d(x) 3D graphs can be generated in Mathcad by going to the graph palette and clicking on either the surface, 3D bar, 3D vector graph icons. Entering an expression wh ich has more than one variable will generate the 3D graph. Integrating multiple expressions into the one 3D graph can be done by using the matrix function by en tering the name of the expression with the two variables, creating a matrix with rows and entering the values into the matrix brackets. Change the appearance of the 3D model is very much the same as the linear 2D graphs as well by right cli cking and selecting the properties menu. A Note to remember is that the whole ex pression is not required to be entered into the graph since you can refer the ex pression via assigned letter as shown within this example. - 10 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Integrating Mathcad with PTC Pro/Engineer Mathcad can be integrated into various programs within PTC products. In this tut orial, we will be looking on how to integrate into Pro Engineer via using the pa rameters as well as relationships within the model in Pro/Engineer. Firstly, sta rt of by creating a part that you want to use in pro engineer. Here we have gene rated a Cylinder for this example. Once completed, we go to the top of the menu and go to tools/ parameters. Next we enter a new parameter, rename the parameter to an appropriate name and then add a Value. Next, move to the right hand side of the menu and insert the units for the height. Click okay to confirm. Next, go to top menu to analysis / external analysis and then to Mathcad analysis, this will open a new dialogue as shown below. At the top of the dialogue, you can loa d previously made Mathcad worksheets or generate a new worksheet to be used in t he analysis. Click new and a new worksheet for Mathcad will open. To create a li nk from Mathcad to Pro/Engineer, it is necessary to use the subscript here in th e expressions that are written out. We linked the subscripted height value back to the word height to make sure that Mathcad is processing it to the correct val ue. We also added an extra line here with height [=] to see if the value is gene rated correctly. Next we need to link the expressions to Pro/Engineer by going t o the properties to the first expression and then going to the Tag Field and typ e proe2mc. This tells the program Pro engineer to get the input field from this Mathcad file. The Last Height Expression we will use and go to properties, Tag a nd type mc2proe. This defines the output field from Mathcad to Pro/Engineer mode l. Once completed Click save and name file accordingly. Now go back to Pro/Engineer to the Mathcad Analysis dialogue, click load and sel ect the Mathcad worksheet that you have created. Next, go down the dialogue to a dd parameter, select the name of the parameter that was created before and next click the input field from Mathcad which was "Height_proe" and click okay. Exit the extra dialogue box and proceed to the output field box in the Mathcad analys is dialogue box. Select the "height_proe" output field defined in Mathcad and to test, we will use the compute button. Once that the value shows that it has wor ked by giving the value we defined in parameters in this example, we click add f eature, name the analysis accordingly and then save. - 11 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Next, go to relationship where we will need to define the relationship of the He ight value on the model with the Mathcad worksheet. To do this we go to the top menu tools / relations and type in the edge to work with, the expression to use found in Mathcad and then where the analysis is located in the feature tree. An example is shown here for the cylinder height. Once completed, test the relationship to see if it is verified by Pro-Engineer a nd then click regenerate. Note to remember is that if you change any values in t he parameters after the model has been regenerated you will have to click the re generate button twice to complete the new changes. This is due to Pro-Engineer d oing the first initial calculations but not displaying the changes in the model. The second regeneration will regenerate the model that is shown graphically. Th ese are just the few of the features available with Mathcad that were shown in t his Basic Tutorial. For additional information of the functions please refer to the tutorial in Mathcad as well as the quick sheets to help you navigate through the multiple functions of Mathcad version 14. - 12 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Mathcad Libraries and Extension Packs Mathcad offers extensive, content-rich math libraries that contain several wellknown reference books delivered as interactive e-books. These engineering discip line-specific libraries include: Mathcad Engineering Libraries Mathcad Civil Engineering Library Combines the encyclopedic Roarks Formulas for St ress and Strain with easy-to-adapt structural design templates and examples of th ermal design problems. Mathcad Electrical Engineering Library Provides hundreds of standard calculation procedures, formulae and reference tables used by electr ical engineers. Mathcad Mechanical Engineering Library Combines the encyclopedic Roarks Formulas for Stress and Strain with easy-to-adapt calculations from a class ic McGraw-Hill reference book, along with an interactive introduction to the fin ite element method. Mathcad Extension Packs contain specialized libraries of functions designed to c omplement and extend Mathcad Professional s built-in function set. These extensi on packs expand Mathcad s capabilities while using standard Mathcad functions an d operators. To extend the capabilities of Mathcad into specific disciplines, fo ur Mathcad Extension Packs are available: Mathcad Extension Packs Mathcad Data Analysis Extension Pack Enables engineers to easily import, manipul ate and analyze data patterns and relationships in Mathcad. Mathcad Signal Proce ssing Extension Pack Offers more than 70 built-in signal processing functions, a dding extensive capabilities for performing analog and digital signal processing , analysis and visualization. Mathcad Image Processing Extension Pack Performs s moothing, crisping, edge detection, erosion and dilation algorithms on color and grayscale imagesuseful in medicine, astronomy, weather, geophysics, geology, for ensics and radar, among other fields. Mathcad Wavelets Extension Pack Facilitate s a new approach to signal and image analysis, time series analysis, statistical signal estimation, data compression analysis and special numerical methods. Eng ineers can create an almost limitless number of functions that duplicate any nat ural or abstract environment - useful for compressing vast amounts of data, as i n fingerprint identification or coding an MRI. - 13 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Industry Specific Examples As mentioned previously, Mathcad has the capability to be tailored to the needs of specific industries or disciplines. Here are just a few examples of the types of applications that Mathcad can be used for. Chemical Analysis (1) Why it is important it consider Mathcad? (2) Working out on how to generate standard curves with higher accuracy and using Mathcad to do the calculations (3 ) Example Case of an Analysis of Dietary Metabolites in urine. Mathcad is a vers atile and powerful mathematical program in which one can be able to do complex c alculations and still be able to complete them in a logical fashion. This is ext remely useful in providing information that correlated among peers. This example will show how this can be achieved. Here we start with the data which is given and is processed into Mathcad by using the Table function which is assess accord ingly by right clicking in the workspace and selecting insert----> and the table . You may note that this example here is done in duplicates to generate a more acc urate result with the standard curve which is required for this assay method. Al so it is good to notice that the workspace can accommodate word or text anywhere within the calculations. Now we come down to the second table which we have her e with the values which are taken out of the UV-Vis spectrometer. Take note to b e able to use the figures later on in Mathcad, you will need to specify the colu mns that are used in the calculations later on. This is done by using the follow ing keys: [x][:][space][m][desired number according to the column needed] - 14 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Now we will specify the data points in which we will be using, so in the next st ep when doing standard deviation calculations, the information is available. Now for the equation of standard deviation can be shorthanded later by using a SD(x ) can be used later on within the worksheet. Now we can go to the insert function options to give us all the necessary equati ons or functions that we require to do simple to complex statistics. This is don e by going to the insert ---> function and within the new dialogue on the left a s shown here. We go to statistics and select the required functions. Note also t hat every time you select another function within the right hand window there is box underneath which gives u a description on what that function does as well a s the shorthand version of the function in Mathcad. This is valuable since you d o not have to come back to the the insert function over and over again. - 15 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

To save time you can see that I am simply cutting and pasting the functions here and editing the values in which the function is to calculate. Simply click with in the function where you want to edit and enter in the new values. Now in case the answer do not automatically change with the new values given go to the top o f the menus and look for the calculate button as shown here or alternatively by using the F9 key and this will perform the calculate function in Mathcad or Crtl F9 to calculate the complete worksheet itself. Now after we have completed all the necessary calculations for the standard curv e to be used her, we can start using the values here to make our standard curved to do our calculations. Go to the Graph bar and select the x,y plot graph. Now to get the values into the graph we just have to click on the bottom middle box here and enter in x and to the left middle box we add in our functions that we n eed which is the y function as well as the r(x) which will give us the line of b est fit. Now completed, to generate the graph simply click outside into the work space. You may notice that the axis of the graph are defined at a undesirable scale. To edit the scale, click the graph once again and you will notice two of additiona l numbers which are part of the graph on the bottom as well as on the left where the axis are. These numbers are your minimum as well as maximum range values on the corresponding axis. Change these numbers to the desired scale you would lik e and click outside into the workspace to regenerate the graph with the new chan ges. To change the Units in which the graph is also spaced out on the axis, righ t click the graph and select format. - 16 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

A new dialogue similar to the one show here will open and click on the options i n the dialogue under the x and y primary axis and un-tick auto grid and set to a desired amount of scale units you would like. Once completed click apply and ok ay. Now that we have the standard curve we can start by working out the amount of ur ea in urine sample, I am going to demonstrate how to integrate excel into Mathca d and vice versa. - 17 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Medical Imaging and Nuclear Medicine Mathcad has a broad range of applications within the medical imaging field. Heres another example of how Mathcad can be tailored to specific industry requirement s. With all radiologist and radiographers, one thing they all know that is impor tant is that the quality of the images taken for the diagnostics must be of the highest quality possible. However, there are many factors that contribute to poo r quality image acquisition such as parameters settings for the scan, image cont rast, contrast sensitivity, distortion, noise as well as artifacts and blurring. Getting that balance between sensitivity and selectivity creates the need for i mage processing a necessity. This example will allow for image processing possib le to be done in MathCAD, which can be used in the medical field where every lit tle detail makes the difference in giving an accurate diagnosis. We will focus o n 5 processes in MathCAD to give quality images without comprising the integrity of the scans taken. 1. Equalisation 2. Function and level mapping 3. Noise and Error measurement 4. Crisping 5. Filtering Noise But why bother using Mathcad to do image processing when other Photoshop programs are available? The answer is simple. Mathcad allows for far greater control on how defined you would like the image to be without comprising the image as well as being able to customize usi ng different algorithms. Also another factor to consider is that the images can be swapped in and out quickly to use the same function or that particular settin g just by changing the address line where the image is located. First of all, we will be using an image which has been provided through PTC for this tutorial. I n the Handbook for image processing, the image which will be used to demonstrate the various features of the image processing pack in Mathcad is brain.gif as sh own here. Through out this tutorial the original image is shown next to the edit ed image which has been enhanced by MathCAD with appropriate names. Equalisation Equalisation allows for the scanned image to be more defined by controlling on h ow the light and dark values are distributed in defined cumulative histogram of the image. This will in turn create a linear looking cumulative histogram of the scanned image and giving sharper details on the image. Now to activate this fun ction, command line typed out as equalize(M) , as M is defined as your image fro m the previous line of calculation to this command. However it is best if you us e a similar layout to what I will be doing for the example of equalisation here: Firstly, define the image in which is being read. The example show here is that I will be using M to define my image from the MathCAD image processing booklet. M :=READ_IMAGE(C:\Program Files\Mathcad\Mathcad 14\Handbook\improc\brain.gif) - 18 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Next I will output the image to a histogram to see the degree of spread of the i ntensities in the 255 greyscale bands. Note that the number 256 is used since th at the intensities start at and include 0 to 255, therefore giving 256 intensiti es). So the command of H:=imhist(M ,256) And for the histogram to work, we need to define the data in which the histogram will be using which is the pixel matri x of the image as we defined as so: k:= 0..rows(H) 1 Next create a Histogram and define the axis accordingly to the Hk as the function and k as the axis values for x and you should get a histogram like this: Seeing the image is slightly dark, we will be spread out the intensities to defi ne the features on the scan to help get a better detailed image of the scan. For this image, the cumulative histogram is given by the difference equation for C. So we will define as the following and repeat the same steps to create a cumula tive histogram as shown with these steps. Cumulative histogram: Now that we can see the slope is not linear from the histogram, we will apply th e equalise function here to see what happens. We do this by typing the following commands to generate the histogram and the new changes shown Requal :=equalize( M) J :=imhist(requal,256) - 19 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

The new cumulative histogram of equalized image generated by typing the followin g commands: Now just generate the cumulative Histogram: Now as we can see the cumulative histogram is showing a relatively linear curve here give us the following images as a result. Now as we can see the newly edited image has more defined features since that th e equalisation has brought out the lines within the Cerebellum is more defined a s well as the sulci and the gyri in the cerebral cortex. - 20 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Function and Level Mapping Function and level mapping shows the different levels of intensities across an e xisting image which will allow for different areas of the image to be more defin ed. This can be done to eliminate the amount of background noise as we saw in th e equalisation step for the first webinar. To activate this function, type in fu nmap(M,f) where M is the image matrix which needs to be generated first. The cha racter f in the command is for the function to be performed at each vector or ce lls in the image matrix (256 levels to map the different intensities) which is g oing to be used to help define the details on the image. This means that every t ime that the image matrix is processed by the new function, the mapping image ma trix will be also calculated with the new changes to the image at each intensity each time separate as it is applied. To use this function, we type in R := READ _IMAGE("C:\Program Files\Mathcad\Mathcad 14\Handbook\improc\brain.gif"). This al lows us to setup first variable for the function mapping. Next we will use a fun ction to help us generate the desired effect. Now there are a number of other fu nctions which can be used for this or custom made for their desired effect. Howe ver this will require doing some experimenting and testing of the function appli ed to the image. For now we will be using the following function to create the d esired effect. Here is a small list of possible functions which can be used for the function ma pping. Once we have completed that we enter in fmap := Re(funmap(R,F)) Since that we have generated the function as well the im age matrix to use, using an output image you can see the results. - 21 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Level Mapping Level Mapping allows for the replacement of the intensities with in a specified image by a specified area or vector of intensity. In other to simply put it, to increase the intensity levels within a specific area by use a defined vector. An example of this can be said to be the same of having a 29th element in a vector will give a new level for the pixels with an intensity of 29. It is important t o note that images have entries within 0 and the length of the vector used of mi nus 1. An example of this is that we would like to create an image with a square d intensity scale. We would create a Vector within: r := 0 255 This will result i n the creation of the following curve constructed given us the what the vector w ill look like. Now given by imaging pack we can use a number of examples as shown here, to refi ne the image for better screening and printing resolution. - 22 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

This therefore, helps in enhancing the image for better diagnosis of the patient . Note to remember is that a particular function map or look-up table can be cre ated with monitor or sensor, which maps irregularities cause by the display to t heir corrected values. Once we are satisfied with the vector created we apply the vector to the Level m apping function with the following command and specify the image to be used in t he level mapping as well. R := READ_IMAGE("C:\Program Files\Mathcad\Mathcad 14\H andbook\improc\brain.gif"). level :=levelmap(R, vec) Error and Noise Measurement With Error and Noise Measurement, we use functions which are based on the relati ve error( squared error ration, the mean squared error and the signal-to-noise r ation between the two images which are used to be compared. These functions are used to determine the level of noise that affects an image after that it is proc essed or transmitted. To demonstrate this function we will be looking at a few e xamples here. Firstly we need to define out variables here: which are R that rep resents out first or control image matrix that we are using. And Q which is the second image matrix , the same size as the first. Note that the functions return a number which represents the relative error, the mean squared error, or the si gnal-to-noise ratio (SNR) between M and Q. Remember that all returned values are in decibels (dB). Now the first of the three commands that we are going to be l ooking at with error and noise measurement is the relative error. This function returns the squared error ratio over all the elements of the two matrices that a re defined by M and Q. This is activated by the command of relerror(M, Q). - 23 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Now to workout the squared error ratio is as follows: Over two matrices, this function rearranged and defined as: After getting the required values for N by working out the ratios, simply type i n the following command to work out the relative error for R: err :=relerror(M , N) err :=0.0666667 To demonstrate the effect of this function, we will be applyi ng this function to our example image here and define it: R := READ_IMAGE("C:\Pr ogram Files\Mathcad\Mathcad 14\Handbook\improc\brain.gif"). Next we will add som e random noise to this image by the following command and then calculate the rel ative error from the image matrix. Q := addnoise(R,.05,128) err :=relerror(R ,Q) err :=0.059 Another way in which you can measure the amount of error in a image is the mean square error function. This gives the average squared error between the selected images of R and Q. For example we can read and define an image fir st. Once we have done that we can apply the requantize to 13 levels on it: R := READ_IMAGE("C:\Program Files\Mathcad\Mathcad 14\Handbook\improc\brain.gif" Q := imquant(R,13) - 24 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

The mean squared error (MSE) is defined as follows: I := 143 J := 234 Next we de fine the Dimensions of images: I :=0..(I-1) J :=0..(J-1) MSE= 41.189 Calculating the MSE with the built-in function we obtain the same result: MSE2 : =immse(R,Q) MSE2 :=41.189 The third of the error and noise measurement functions in this section, is the SNR or the Signal to Noise Ratio. This command calculat ed the singal to noise ration of an image in decibels (dB). For example, lets say when transmitting a scanned image between diagnosticians via a communication ch annel. The receive we observe the same image, but is corrupted by some noise int erference. We will mimic or recreate this situation by applying the first scan a s follows: Q :=addnoise(R,0.3, 150) The SNR is defined as the ration of the averages of power between the original a nd of the noise itself. The noise is obtained by subtracting the original image matrix with the recreated noisy image. To activate this function by typing in th e function: SNR :=imsnr(R,Q) This gives us a value of 3.57 (dB) Now another comm only used function in image integrity is peak signal to noise ratio (PSNR). This function can be activated by using the following command: Where A is defined by the image quality used (8 24bit, A = 255 for 8bit and A=40 95 for 12 bit) - 25 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Crisping Sharpening the details of image is important to give definition to the image whe n diagnosing a patient. Mathcad provides crisping functions which help in this m atter. They are as follows: orthogonal crisping (R) dia crisping(R) uni crisping (R) orthogonal5 crisping(R) All of these functions work by the convolution of th e specific crisping kernel within an selected matrix defined as R. The Number in the orthongal5 shows that the 5 x 5 kernel is used instead of a 3 x 3 kernel. C risping can be used to restore lost sharpness to an image which as degraded due to transmission or image processing. The command will result in giving out a mor e defined or crisper image matrix. The edges remain unchanged since the kernel d oesnt overlap completely in these areas. These are the matrix kernels that are us ed for the following functions Now to use any of these functions, firstly define the image to be used and then define the command to be used. For Example, we will use the same scan through th is webinar R := READ_IMAGE("C:\Program Files\Mathcad\Mathcad 14\Handbook\improc\ brain.gif" Next we blur the image and crisp the image again. R :=orthosmooth(R) Orthogonal := orthocrisp(R) Due to the nature of Crisping functions allowing ful l floating point calculations and compression of image values, we would need to rescale and equalize to spread the values out again. So in order to save time an d space in the worksheet, we will combine these functions all into single line c ommands as shown here: Orthogonal :=equalize(scale(orthogonal(R),0,255)) dia :=e qualize(scale(diacrisp(R),0,255)) uni :=equalize(scale(unicrisp(R),0,255)) Ortho 5 :=equalize(scale(orth5(R),0,255)) Here are some examples of combining commands and the results of crisping the original Image. - 26 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Noise Filtering Noise filtering requires experience in the types of noise that the person is dea ling with in each image. Depending on what generated the noise, what sort of edg e distortions are acceptable in the output and what sort of noise it is will gre at depend on what sort of filtering which will be used. We will start of with a simple scattering of noise (otherwise known as salt and paper noise). We will si mulate this and see if this can be reversed. Orig :=READ_IMAGE(C:\Program Files\M athcad\Mathcad 14\Handbook\improc\brain.gif) Noisy: = addnoise(orig,.2,128) Now t o remove this type of noise there are two ways in which can be done to this. Fir stly, the use of an averaging function such as smoothing or secondly a more comp lex method of median filtering. So we will look at the first method of doing thi s the smoothing filtering. Smoothing of the image can be done by the following c ommand: Smooth := unismooth(noisy) To use the median filtering, type in the foll owing command: Med :=medfilt(noisy) Now the following images will show the diffe rence of the filtering methods as we show the orginal image, the noise generated one, smoothing and the median filtering images. - 27 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

As the images prove, the median filtering is a better filtering method for the s catter noise because it doesnt change the intensity levels of the images, but use s what is available in the image. To observe these levels, 4 histograms are prov ide from each image to see the differences between them. To enable this simply t ype in Intensity := imhist(,256) k:= 0.. length(intensity1) 1 As shown through the histogram, the original and the median filtering histogram exhibit very similar intensities proving that median filtering is a much more a ppropriate method in filtering the noise. Median filtering is a better way to fi lter this type of noise because it does not change the intensity levels in the i mage, but only uses available levels. To see this, look at the histograms of the four images. - 28 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Preconditioning Data This example will show how smoothing functions can be used In Mathcad to precond ition data before further analysis can be conducted. Data analysis is used in a variety of industries including business, science and social sciences. It involv es gathering information, modelling and transforming data into information can t hat be used to suggest conclusions and support decision making. It is therefore essential to be able to analyse this data quickly and efficiently. Many of todays applications require measuring, or creating a precise signal in a very noisy en vironment. This may require the use of smoothing filters however some built-in f ilters tend to over-smooth data, removing important features. MathCAD allows for greater control in order to obtain the desired level of filtering required for a specific task. The smoothing functions act to remove noise from data in a numb er of ways. In this webinar I will be discussing 3 different types of smoothing filters available in MathCAD. 1. medsmooth 2. supsmooth 3. vsmooth (new in Mathc ad 14) Lets consider some data: Sampled at specified intervals: Inject noise in every fifth sample - 29 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Median Smoothing The medsmooth function takes a vector of real data, x, and smooths it using a wi ndow of length n. The median (midpoint) of the n points surrounding each data po int is used to replace the data point, as is suggested in this diagram for a win dow of length 5: As you can see in this particular data set of 5 values indicate d by the blue line, the median (midpoint) falls into the number 3. It is clear that this graph is significantly cleaner than the original. Median smoothing is particularly useful in cases where there are sudden bursts o f noise or incidents of corruption in the data. It is generally preferred over m ean smoothing, which has a tendency to blur sharp features in data. Super smoothing Consider a cloud-like data set created by corrupting a cosine curve: - 30 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

The supsmooth function takes x data in strictly increasing order (no two x value s can be the same). It uses a fast algorithm which sorts through the cloud of da ta to produce a reasonable periodic pattern. Similar results are obtained from k ernel smoothing, but the calculation takes longer. Repeated smoothing The smoothing process can be repeated until no additional changes occur on succe ssive applications. The programmed function Smooth below demonstrates this techn ique. The program will also terminate after 100 applications of medsmooth even i f this steady state is not reached. Consider the data - 31 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

..you can see the effect of different window lengths, and also the plateaus that arise from "sanding" this data too much. VSmooth is the new built-in function which is a variation on the preceding metho d. It takes a data set x and a vector of window values W1. The function Smooth i s applied successively to the data for each value in the window vector. The data is first smoothed repeatedly until there s no change using a window of then applies the process to and finally smooths as much as possible with as the window width. You can also provide a scalar value for W, in which case on ly a single window width is used repeatedly. - 32 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Other "smoothers" You may wish to consider various regression techniques as smoothing methods, sin ce fitting a curve to a set of data amounts to finding a smooth function that ap proximates the data. If you evaluate the function at every original data point i n x, you will get a smoothed version of the y data. These smoothers form a core of basic techniques. Other special-purpose built-in functions for smoothing one and two-dimensional data sets are available in the Signal Processing Extension P ack and the Image Processing Extension Pack, available from CADDIT. - 33 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

Descriptive Statistics This next example will explain some of the basic concepts involved within the fi eld of descriptive statistics and how these can be done easily in Mathcad. Descr iptive statistics is commonly used in the field of medical research studies. It is used to quantitatively describe the main features of a set of data. Inferenti al statistics differs in that it is used to reach conclusions that generalise be yond the immediate data. Descriptive statistics are used to present quantitative descriptions of large amounts of data in a clear and understandable way. Mathca d offers a variety of descriptive statistical functions to reduce large amounts of data into a much simpler summary. Descriptive statistics are generally presen ted along with more formal analyses, to give the audience an overall sense of th e data being analysed. I plan to go through the following basic functions: 1. me an(A,B,C,...) 2. median(A,B,C,...) 3. mode(A,B,C,...) 4. percentile(v,p) These f unctions take single or multiple scalars or arrays, and return the mean, median, and mode, respectively, giving measures of the location of a data point relativ e to the rest of the distribution. The best choice of location estimator depends on the general dispersion or distribution of your data. Mean In statistics we refer to this also as the "arithemetic mean" and is the most co mmonly used type of average. To calculate the mean of a set of numbers this invo lves simply adding the total sum of the numbers in a set divided by the number o f items in the set. The other types of averages such as the median and th mode w ill be discussed later on. Example: Consider the following numeric data: The arithmetic mean or average of N values is given by the following formula: The mean is sensitive to changes in values of one or more data points: - 34 Using Mathcad, Published by CADDIT Australia, Mathcad Sales & Support - http: //www.caddit.net/

The mean is greatly affected by significant outliers. So you may find that the m ean is a poor description of the central location if this is the case. You may c hoose to trim the outliers and find the "trimmed mean" for a better estimate. Co nsider the "trimmed" numeric data: As you can see I have chosen to leave out the value 46 which was a significant o utlier in this set. MathCAD automatically readjusts all the values of the formulas and recalculate t he new mean for this data set. Median The median, or "middle value," of a set of data is another description of centra l location. The median depends on the relative positions of the data, not on the actual values of every data point, and so is relatively insensitive to small ch anges in individual data values. Mathcad s median function does not accept compl ex numbers. A median is the value falling in the middle when data are sorted in ascending order (smallest to largest). Example: If there are an odd number of data, there is one data value which is the median. e.g. if a