Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

MATLAB® is a mathematical programme developed by the company called The MathWorks Inc. Examples in this chapter have been tested on MATLAB versions between 2011a and 2015b. It is expected that most of the commands presented will work with some earlier versions, as well as most later versions. It will be assumed that the reader has a basic understanding of MATLAB, can write MATLAB statements, understands basic MATLAB commands, and can plot a simple MATLAB graph. This chapter will examine in detail additional features, such as the different toolboxes and formatting features. In order to clearly distinguish between the code required for the MATLAB function and text, all MATLAB commands and variables are shown in bold Courier New.

7.1 Basic Statistical Functions

The functions presented in this section are available with all standard MATLAB installations and do not require purchasing any additional toolboxes or licences. The most common statistical functions are listed in Table 7.1.

Table 7.1 Basic statistics functions

7.2 Basic Functions for Creating Graphs

A list of functions for creating different types of graphs is listed in Table 7.2. Functions with an asterisk after them require installation of the Statistics and Machine Learning Toolbox in MATLAB. In pre-2013 versions of MATLAB, this toolbox is called the Statistics Toolbox.

Table 7.2 Basic plotting functions (functions followed by an asterisk (*) require the Statistics and Machine Learning Toolbox)
Table 7.3 Useful formatting options

7.3 The Statistics and Machine Learning Toolbox

This section lists those statistical functions that require the Statistics and Machine Learning Toolbox in MATLAB to be installed. In pre-2013 versions of MATLAB, this toolbox is called the Statistics Toolbox.

7.3.1 Probability Distributions

Detailed information regarding the definitions of the different probability density functions and the meaning of the required variables can be found in Sect. 2.4. Table 7.4 presents a summary of the available functions.

Table 7.4 Probability distribution functions

7.3.2 Advanced Statistical Functions

The functions listed in Table 7.5 are useful for computing more advanced statistical properties.

Table 7.5 Advanced statistical functions

7.3.3 Useful Probability Functions

A summary of useful probability functions is given in Table 7.6.

Table 7.6 Useful probability functions

7.3.4 Linear Regression Analysis

There are two main functions for performing linear regression in MATLAB: regress and nlinfit. The first works for linear regression, while the second works for nonlinear regression. Weighted, linear least squares can be performed using lscov. Detailed information about the different commands and their requirements is given in Table 7.7.

Table 7.7 Linear regression functions

7.3.5 Design of Experiments

The functions listed in Table 7.8 are useful when performing design of experiments or their analysis.

Table 7.8 Design of experiment functions

7.4 The System Identification Toolbox

The System Identification Toolbox in MATLAB is a very useful toolbox when fitting models for system identification using the prediction error model. It provides a convenient and concise way of storing, accessing, and manipulating different data sets and their associated models. Although most time series analyses can be performed using the System Identification Toolbox, at times it is easier to use the econometric toolbox described below. In order to fully appreciate and use the System Identification Toolbox, it is first useful to examine in detail the special data objects that store and hold the information: the iddata and the idpoly objects.

The iddata object, which will be denoted by a generic z, stores the data that is used in determining the models. It consists of 2 main fields:

  1. 1.

    The inputs to the system are stored in z.u, which is a matrix. Each of the columns contains a different input.

  2. 2.

    The outputs from the system are stored in z.y, which is a matrix. Each of the columns contains a different output. Thus, the second output of the system would be accessed as z.y(:,2), regardless of how the variables may be named on the screen.

Additional fields include:

  • z.Tstart, which stores the value of the starting time for the object.

  • z.Ts, which stores the value of the sampling time.

The iddata object can be treated as a vector to access all the relevant data between two end points. For example, to take the data located from the 1st to 100th point in the object, the command would be z(1:100).

The idpoly object, which will be denoted by a generic m, stores information about the model that has been fit to the data. It consists of five main fields that consist of the coefficients, a i , ordered in descending powers of z −1, given by

$$ 1+{\displaystyle \sum_{i=1}^n{a}_i{z}^{-i}} $$

where n is the order of the system. Each of the fields is the same length. The fields are given the names, A, B, C, D, and F, and represent the coefficients of the following model:

$$ A\left({z}^{-1}\right){y}_k=\frac{B\left({z}^{-1}\right)}{F\left({z}^{-1}\right)}{u}_{k-d}+\frac{C\left({z}^{-1}\right)}{D\left({z}^{-1}\right)}{e}_t, $$

where d is the discrete time delay, which for a zero-order hold is one more than the continuous time delay. The coefficients of A(z −1) would be accessed using m.A. Note that the definition of the B-polynomial in MATLAB is different from the definition used in the other chapters. This difference implies that the time delay, d, must be increased by 1 from the values obtained in the other chapters, that is, d = n k + 1. This is because MATLAB requires the time delay due to sampling to be explicitly noted in the definition of the function.

For multi-input systems, where there are multiple inputs, the model representation is converted into a matrix form, so that each row represents a different input and the columns represent the parameter specifications. The orders are then stored as the augmented column matrix with each column representing the orders of a different row, for example, the B-order would be specified as [2, 3] for a 2-input system.

The most important functions from the System Identification Toolbox are given in Table 7.9 for creating the data object, Table 7.10 for creating the model, Table 7.11 for validating the model, and Table 7.12 for designing the system identification experiment.

Table 7.9 System Identification Toolbox: Functions for creating the data object
Table 7.10 System Identification Toolbox: Functions for creating a model
Table 7.11 System Identification Toolbox: Functions for validating a model
Table 7.12 System Identification Toolbox: Functions for designing a system identification experiment

7.5 The Econometrics Toolbox

The Econometrics Toolbox contains some useful tools for analysing and preprocessing time series data. It is especially useful for fitting seasonal models. Unfortunately, not all the validation functions can be as easily obtained with this toolbox. Table 7.13 contains the required functions for creating an econometric model, Table 7.14 contains the functions for creating various types of correlation plots, Table 7.15 contains the functions for estimating the model parameters of econometric functions, and Table 7.16 contains useful functions for model validation.

Table 7.13 Econometrics Toolbox: Functions for creating the data object
Table 7.14 Econometrics Toolbox: Functions for creating various correlation plots
Table 7.15 Econometrics Toolbox: Functions for estimating model parameters
Table 7.16 Econometrics Toolbox: Functions for validating the model

7.6 The Signal Processing Toolbox

The Signal Processing Toolbox contains complementary functions that can be used to create cross- and autocorrelation plots without using the Econometrics Toolbox. It can also be used to effectively create periodograms. Table 7.17 contains a summary of the useful functions.

Table 7.17 Signal Processing Toolbox: Functions for analysing signals

7.7 MATLAB® Recipes

This section provides useful MATLAB code for various functions that are not provided by default in MATLAB. This code can be reused, but full attribution both to the author and this book must be made.

7.7.1 Periodogram

  • Requirements: None

  • Goal: Given a data series yt return the corresponding periodogram on the region [0, 0.5].

  • File Name: periodogram2.m

    function periodogram2(yt)

    %Custom-built function that creates the periodogram for a given signal

    %Inputs:

    % yt: signal for which the periodogram is desired.

    %Copyright 2014: Yuri Shardt

    %Distributed as part of the book Statistics for Chemical and Process

    %Engineers: A Modern Approach, published by Springer Verlag.

    %Checking the data

    q=size(yt);

    N=length(yt);

    if (N<5)

        error('Please make sure that the size of yt is at least 5 samples.');

    end

    if (N==q(1) && q(2)~=1) || (N==q(2) && q(1)~=1)

     error('Please make sure that yt is either a row or column vector.');

    end

    y=detrend(yt,0);

    %Perform the Fast Fourier Transform

    X1=abs(fft(y,N));

    X=fftshift(X1);

    if (mod(N,2)==0)

     F=[-(N)/2:(N)/2-1]/N;

     count=N/2+1;

    else

     F=[-(N-1)/2:(N-1)/2]/N;

     count=(N-1)/2+1;

    end

    %Creating the plot

plot(F(count:end),X(count:end)/N*2,'-k')

    xlabel(['Frequency, $f$, (cycles/sample)'],'interpreter','latex'),ylabel('Amplitude, $|y|$','interpreter','latex')

    end

7.7.2 Autocorrelation Plot

  • Requirements: Signal Processing Toolbox (xcorr)

  • Goal: Given a data series yt return the corresponding autocorrelation plot for 20 lags.

  • File Name: autocorrelation.m

    function autocorrelation(yt)

    %Custom-built function that creates the autocorrelation plot for a given

    %signal. A lag of 20 is the maximum lag considered.

    %Inputs:

    % yt: signal for which the autocorrelation plot is desired.

    %%Copyright 2014: Yuri Shardt

    %Distributed as part of the book Statistics for Chemical and Process

    %Engineers: A Modern Approach, published by Springer Verlag.

    %Checking the data

    q=size(yt);

    N=length(yt);

    lag=20;

    if (N<lag)

     error('Please make sure that the size of yt is at least 20 samples.');

    end

    if (N==q(1) && q(2)~=1) || (N==q(2) && q(1)~=1)

     error('Please make sure that yt is either a row or column vector.');

    end

    y=detrend(yt,0);

    %Obtain the autocorrelation values

    q=xcorr(y,y);

    count=N;

    %Creating the plot

    plot([0:lag],q(count:count+lag)/max(q),'ok')

    grid on

hold on;plot([0,lag],tinv(0.975,N)*[1,1]/sqrt(N),'--k','linewidth',2)

    plot([0,lag],-tinv(0.975,N)*[1,1]/sqrt(N),'--k','linewidth',2)

    plot([0,lag],[0,0],'-k')

    xlabel(['Lag (samples)'],'interpreter','latex'),ylabel('Autocorrelation, $\rho$','interpreter','latex')

    end

7.7.3 Correlation Plot

  • Requirements: None

  • Goal: Given a matrix of correlations, correlation creates the two-dimensional correlation plot.

  • File Name: corrplot1.m

    function corrplot1(correlation,tags,title1,axis1)

    %Custom-built function that creates the corelation plot given a correlation matrix

    %Inputs:

    % correlation: correlation matrix

    % tags: alphanumeric explanation of the columns in the data set (should not be left blank)

    % title1: a title for the figure (can be left blank)

    % axis1: the lable for the axis (can be left blank)

    %Copyright 2014: Yuri Shardt

    %Distributed as part of the book Statistics for Chemical and Process

    %Engineers: A Modern Approach, published by Springer Verlag.

    [a,b]=size(correlation);

    imagesc(abs(correlation));colorbar;colormap(jet)

    set(gca, 'XTick', 1:a); % center x-axis ticks on bins

    set(gca, 'YTick', 1:a); % center y-axis ticks on bins

    set(gca, 'XTickLabel', tags); % set x-axis labels

    set(gca, 'YTickLabel', tags); % set y-axis labels

    title(title1); % set title

    xlabel(axis1);

    ylabel(axis1);

7.7.4 Cross-Correlation Plot

  • Requirements: Signal Processing Toolbox (xcorr)

  • Goal: Given 2 data series yt and zt return the corresponding cross-correlation plot for ±20 lags.

  • File Name: crosscorrelation.m

   function crosscorrelation(xt,yt)

   %Custom-built function that creates the crosscorelation plot for 2 signals.

   %A maximal lag of +-20 is assumed.

   %Inputs:

    % x: signal 1

    % y: signal 2

    %Copyright 2014: Yuri Shardt

    %Distributed as part of the book Statistics for Chemical and Process

    %Engineers: A Modern Approach, published by Springer Verlag.

    %Checking the data

    q1=size(xt);

    N1=length(xt);

    q2=size(yt);

    N2=length(yt);

    lag=20;

    if (N1~=N2)

     error('Please make sure that both signals have the same length');

    end

    if (N1<2*lag || N2<2*lag)

     error('Please make sure that the size of yt and zt are at least 40 samples.');

    end

    if (N1==q1(1) && q1(2)~=1) || (N1==q1(2) && q1(1)~=1) || (N2==q2(1) && q2(2)~=1) || (N2==q2(2) && q2(1)~=1)

     error('Please make sure that both yt and zt is either a row or column vector.');

    end

    x=detrend(xt,0);

    y=detrend(yt,0);

    %Obtain the autocorrelation values

    q=xcorr(y,x);

    count=N1;

    N=N1;

    %Creating the plot

    plot([-lag:lag],q(count-lag:count+lag)/std(x)/std(y)/N1,'ok')

    grid on

  hold on;plot([-lag,lag],tinv(0.975,N)*[1,1]/sqrt(N),'--k',' linewidth',2)

    plot([-lag,lag],-tinv(0.975,N)*[1,1]/sqrt(N),'--k','linewidth',2)

    plot([-lag,lag],[0,0],'-k')

   xlabel(['Lag (samples)'],'interpreter','latex'),ylabel('Crosscorrelation, $\rho_{YZ}$','interpreter','latex')

    end

7.8 MATLAB® Examples

This section presents three examples that show how to implement various forms of regression analysis in MATLAB. The topics considered are linear regression, nonlinear regression, and system identification. All examples are based on real data obtained from experiments. Appropriate MATLAB code, as well as the final results, is provided so that the reader can modify these examples to fit their particular needs.

7.8.1 Linear Regression Example in MATLAB

This example examines the problem of fitting a theoretical equation to experimental data in order to obtain the values of the different constants in the system. Detailed information about the problem can be found in Prickett et al. (2011); Elliott et al. (2007); Prickett et al. (2010); and Jochem and Körber (1987). Data provided courtesy of Dr. Richelle Prickett.

7.8.1.1 Problem Statement for Linear Regression Example

Consider the problem of obtaining the values of the parameters in a theoretical equation that describes the osmotic pressure of the sodium chloride (NaCl) salt and hydroxyethyl starch (HES, chemical formula (C6H10O5) m (C2H5O) n ). Based on the virial equation of state, it is assumed that the following equation can be used to describe the osmolality (Π) of such a mixture

$$ \varPi ={B}_3{m}_3^2+{B}_3{k}_{diss}{m}_2{m}_3+{C}_3{m}_3^3+{k}_c $$
(7.1)

where B 3 and C 3 are the virial parameters to be determined, m 2 is the molality of NaCl in millimol/kg of solvent, m 3 is the molality of HES in millimol/kg of solvent, k diss is the disassociation constant that is equal to 1.678, and k c is a known constant that depends on the system being analysed. An experiment was run where the ratio of the mass of HES to the mass of NaCl was fixed to 0.5. The results obtained are shown in Table 7.18.

Table 7.18 Fitting the virial equation (MATLAB example)

7.8.1.2 Solution for Linear Regression Example

Before linear regression can be applied, the above equation must be re-arranged so that all known constant information is on the left-hand side and all the unknown variables are on the right-hand side. Thus, the equation would be rewritten as

$$ \varPi -{k}_c={B}_3\left({m}_3^2+{k}_{diss}{m}_2{m}_3\right)+{C}_3{m}_3^3 $$
(7.2)

The required variables would be defined as

$$ \begin{array}{c}y=\varPi -{k}_c\\ {}\overrightarrow{x}=\left\langle {m}_3^2+{k}_{diss}{m}_2{m}_3,{m}_3^3\right\rangle \\ {}\kern-4.95em \overrightarrow{\beta}={\left\langle {B}_3,{C}_3\right\rangle}^T\end{array} $$
(7.3)

In order to obtain the parameter estimates and analyse the results, the following MATLAB script will be used:

    %Script for solving linear regression problems in MATLAB

    %Copyright 2015 Yuri Shardt

    %To be used in conjunction with Chapter 7 of the Springer book, Statistics

    %for Chemical and Process Engineers: A Modern Approach.

    %Entering the raw data

    m2=[0 600 1268 2013 2852 3803 4889]';

    m3=[0 0.039 0.0823 0.1307 0.182 0.2469 0.3175]';

    kc=[0 1052 2326 3879 5792 8170 11161]';

    pi=[0 1314 2267 3712 5496 8035 11513]';

    kdiss=1.678;

    %Creating the required data matrices for solving the problem.

    y=pi-kc;

    A=[m3.^2+kdiss*m2.*m3 m3.^3]; %Note the use of the dot operator

    %Add code here for Part 2.

    %Solve the problem to obtain the parameter estimates and associated

    %information

    [param,CI,residual,sr,info]=regress(y,A);

    %display the results

    fprintf(['B_3: %f±%f\n'],param(1),(CI(1,2)-CI(1,1))/2);

    fprintf(['C_3: %f±%f\n'],param(2),(CI(2,2)-CI(2,1))/2);

    %display the statistics

    fprintf(['R^2 = %f\n'],info(1));

    %examine the residuals

    normplot(residual);

    figure;plot(y,residual,'ok');xlabel('Measured value');ylabel('Residual');

    figure;plot(A(:,1),residual,'ok');xlabel('First Regressor');ylabel('Residual');

    figure;plot(A(:,2),residual,'ok');xlabel('Second Regressor');ylabel('Residual');

    figure;plot(A*param,residual,'ok');xlabel('Predicted value');ylabel('Residual');

    figure;plot(residual,'ok');xlabel('Sample');

    ylabel('Residual');

The output from MATLAB is:

    B 3 : -0.8206±0.624

    C 3 : 77,469±55,563

    R 2 = 0.731103

The figures are shown in Fig. 7.1. It is clear from examining these figures that the second data point seems to be quite the outlier with an error that is much larger than any of the other data point. Other than this single outlier, the data set looks quite good. Even though the data sample is small, it would be worthwhile to remove this point and see how the regression changes. The previous MATLAB code is changed by adding, after defining the regression matrices, the lines:

Fig. 7.1
figure 1

Linear regression example: MATLAB plots of the (top, left) normal probability plot of the residuals, (top, centre) residuals as a function of y, (top, right) residuals as a function of the first regressor, x 1, (bottom, left) residuals as a function of x 2, (bottom, centre) residuals as a function of \( \widehat{y} \), and (bottom, right) a time series plot of the residuals

    y=y([1, 3:length(y)]);

    A=A([1, size(A,1)],:);

The output from MATLAB becomes:

    B 3 : -0.8535±0.168

    C 3 : 80,344±14,965

    R 2 = 0.982121

It can be seen that the confidence intervals have decreased markedly and the R 2 is now almost 1. This strongly suggests that the removed data point was an outlier. Given the small sample size, the residual analysis graphs do not give any additional information. Practically speaking, the background regarding the outlier would need to be investigated in order to confirm that it is indeed an outlier. If after examining there were no data collection or input errors, then the presence of the outlier could suggest that the model was not appropriate for the data set. It is always important to provide detailed reasons for why a given point was removed as an outlier, especially if there is access to the original data.

7.8.2 Nonlinear Regression Example in MATLAB

This example examines the problem of fitting a theoretical equation to experimental data in order to obtain the values of the different constants in the system. Unlike the previous case, nonlinear regression must be performed in order to obtain a result. Detailed information about the problem can be found in Ross-Rodriguez (2009). Data provided courtesy of Dr. Lisa Ross-Rodriguez.

7.8.2.1 Problem Statement for Nonlinear Regression Example

Consider the problem of obtaining a relationship for the ratio between the equilibrium and isotonic cell volumes given the osmotic pressure. The theoretical relationship can be written as

$$ \frac{V}{V_0}=\left(1-{b}^{*}\right)\frac{-1+\sqrt{1+4B{\varPi}_0}}{-1+\sqrt{1+4B\varPi }}+{b}^{*} $$
(7.4)

where both B and b* are the parameters to be determined and Π 0 is a known osmotic value. The experimental data is provided in Table 7.19. For this data set, Π 0 has a value of 0.293.

Table 7.19 Equilibrium cell volume data (MATLAB example)

7.8.2.2 Problem Solution for Nonlinear Regression Example

In order to solve the problem in MATLAB, the function for which the parameter estimates are being obtained needs to be written as a MATLAB function. It is very important that the following points be considered when writing the function:

  1. 1.

    First, it must be able to deal with vector entries, that is, the dot operators should be used with times (*) and divide (/) to give (.*) and (./).

  2. 2.

    Second, the header of the function must be correctly specified. The order of the inputs is parameter values, regressor values, and measured values. Each entry is assumed to be a matrix of appropriate size. The output is a single vector containing the results. Therefore, the header will be of the form

    y=functionName(parameters,A,y).

Based on these constraints, the following MATLAB function was written. It should be saved in the same location as the script that will be used to run the nonlinear regression.

    function [y1]=volume(beta,x,y)

    %Function to compute the predicted cell volumes given

    % beta: the parameter coefficients

    % x: the corresponding regressors

    % y: the correspindg measured values

    %Copyright 2015 Yuri Shardt

    %Written as part of the Springer book Statistics for Chemical and Process

    %Engineers: A Modern Approach

   y1=(1-beta(1))*(-1+sqrt(1+4*beta(2)*0.293))./(-1+sqrt(1+4*beta(2)*x))+beta(1);

The following script was used to solve the nonlinear regression problem. The initial guess for the parameter estimates needs to be made carefully, as it can impact the ability of the system to give an answer. If possible, using the estimate obtained using the linearised model is a good idea.

    %Script for solving linear regression problems in MATLAB

    %Copyright 2015 Yuri Shardt

    %To be used in conjunction with Chapter 7 of the Springer book, Statistics

    %for Chemical and Process Engineers: A Modern Approach.

    %Entering the raw data

    VVo=[1.00034 0.80465 0.75358 0.71548 0.68588 0.66600 0.65913 0.64004 0.62661];

    pi=[0.29278 0.57172 0.85514 1.13595 1.43349 1.72908 2.02815 2.32660 2.66704];

    %Solve the problem to obtain the parameter estimates and associated

    %information

    [param,residual,J,covb] = nlinfit(pi,VVo,'volume',[0.2,0.56]);

    CI=nlparci(param,residual,'covar',covb);

    %display the results

    fprintf(['b*: %f±%f\n'],param(1),(CI(1,2)-CI(1,1))/2);

    fprintf(['B: %f±%f\n'],param(2),(CI(2,2)-CI(2,1))/2);

    %examine the residuals

    normplot(residual);

    figure;plot(VVo,residual,'ok');xlabel('Measured value');ylabel('Residual');

    figure;plot(pi,residual,'ok');xlabel('First Regressor');ylabel('Residual');

    figure;plot(residual,'ok');

    xlabel('Sample');ylabel('Residual');

Note that the parameter estimates may be slightly different from those obtained here due to differences in the way the optimising engine works. The MATLAB output is:

    b*: 0.5245±0.0436

    B: 2.408±3.616

From here, it is easy to note that the B parameter is not significant and its value could be zero. This suggests that potentially not enough data have been collected to make an appropriate estimate. The residual plots are shown in Fig. 7.2. This figure seems to show that there is some trend to the residuals. However, given the rather small sample, it is hard to discern exactly what this trend may be. Since it has been assumed that the given equation holds, in order to obtain a better understanding of the data, additional experiments should be provided.

Fig. 7.2
figure 2

Linear regression example: MATLAB plots of the (top, left) normal probability plot of the residuals, (top, right) residuals as a function of Π, (bottom, left) residuals as a function of \( \widehat{y} \), and (bottom, right) a time series plot of the residuals

7.8.3 System Identification Example in MATLAB

The final example will consider the problem of system identification using the same data as used in Sect. 6.6: Modelling the Water Level in a Tank. For this reason, only the code required to model the level in Tank 1 will be presented. After making the relevant changes in the figure formatting, the given figures will be obtained. This code requires the use of the System Identification Toolbox. The function can be called as follows: systemidentification([1 2],1 1,[1 2],[1 2]) where, since there are two inputs, the values of n b , n f , and n k are entered as vectors with each entry represents the individual cases.

    function z=systemidentification(nb,nc,nd,nf,nk)

    %Function to obtain system identification models of the data assuming a

    %Box-Jenkins model with parameter orders nb, nc, nd, and nf with a time

    %delay of nk.

    %Copyright 2015 Yuri Shardt

    load SystemIdentificationData;

    newy1=Lower_Left_Level;

    qnew=size(newy1);

    %Plot the raw data

    subplot(2,2,1), plot(U1)

    xlabel('time (s)')

    ylabel('flow rate, u (cm/s)')

    title('Signal 1')

    subplot(2,2,2), plot(U2)

    xlabel('time (s)')

    ylabel('flow rate, u (cm/s)')

    title('Signal 2')

    subplot(2,2,3), plot(newy1)

    xlabel('time (s)')

    ylabel('height, h (m)')

    title('Tank 1')

    %Create the data to store the object

    z1=iddata([newy1],[U1,U2],1);

    z1=detrend(z1,0);

    %Obtain the parameter estimates

    z=processbj(z1,nb,nc,nd,nf,nk,qnew);

    end

    function modelBJ=processbj(z1,nb,nc,nd,nf,nk,q)

    %Partition the data set

    split=ceil(2*q(1)/3);

    %Obtain the parameter estimates

    modelBJ=bj(z1(1:split),'nb',nb,'nc',nc,'nd',nd,'nf',nf,'nk',nk);

    %Display the results

    present(modelBJ)

    %Plot the required residual analysis figures

    figure

    compare(modelBJ,z1(split+1:end))

    figure

    resid(modelBJ,z1(split+1:end)) %Note that the programme will pause here in order to for the first graph to be examined before displaying the next one.

    r=resid(modelBJ,z1(split+1:end));

    figure

    normplot(r.OutputData);

    end

7.9 Further Reading

The following are references that provide additional information about the topic:

  1. 1.

    General MATLAB Help:

    1. (a)

      Sizemore J, Mueller JP (2015) MATLAB for dummies. Wiley, Hoboken

    2. (b)

      Hunt BR, Lipsman RL, Rosenberg J (2014) A guide to MATLAB: for beginners and experienced users: updated for MATLAB 8 and Simulink 8, 3rd edn. Cambridge University Press, Cambridge, UK

  2. 2.

    Linear Regression Data Set:

    1. (a)

      Elliott JA, Prickett RC, Elmoazzen HY, Porter KR, McGann LE (2007) A multisolute osmotic virial equation for solutions of interest in biology. J Phys Chem B 111:1775–1785

    2. (b)

      Prickett RC, Elliott JA, McGann LE (2010) Application of the osmotic virial equation in cryobiology. Cryobiology 2010:30–42

    3. (c)

      Prickett RC, Elliott JA, McGann LE (2011) Application of the multisolute osmotic virial equation to solutions containing electrolytes. J Phys Chem B 115:14531–14543

    4. (d)

      Jochem M, Körber C (1987) Extended phase diagrams for the ternary solutions H2O − NaCl − glycerol and H2O − NaCl − hydroxyethylstarch (HES) determined by DSC. Cryobiology 24:513–536

  3. 3.

    Nonlinear Regression Data Set:

    1. (a)

      Ross-Rodriguez LU (2009) Cellular osmotic properties and cellular responses to cooling. University of Alberta, Edmonton