# Introduction to Chemical Engineering Processes/MATLAB

## Contents

## Introduction to MATLAB[edit]

## Inserting and Manipulating Data in MATLAB[edit]

### Importing Data from Excel[edit]

### Performing Operations on Entire Data Sets[edit]

## Graphing Data in MATLAB[edit]

### Polynomial Regressions[edit]

MATLAB is able to do regressions up to very large polynomial orders, using the "polyfit" function. The syntax for this function is:

polyfit(XDATA, YDATA, Order)

The x data and y data must be in the form of *arrays*, which for the purposes of this application are simply comma-separated lists separated by brackets. For example, suppose you want to perform the same linear regression that had been performed in the "linear regression" section. The first step is to define the two variables:

>> XDATA = [1.1,1.9,3.0,3.8,5.3]; >> YDATA = [559.5,759.4,898.2,1116.3,1308.7];

Then just call polyfit with order '1' since we want a linear regression.

>> polyfit(XDATA, YDATA, 1) ans = 1.0e+002 * 1.77876628209900 3.91232582806103

The way to interpret this answer is that the first number is the slope of the line (1.778*10^2) and the second is the y-intercept (3.912*10^2).