image thumbnail

MKXLSFUNC: Easily integrate legacy spreadsheet tools into MATLAB

by

 

19 Feb 2013 (Updated )

Creates an m-file function that does analysis within your specified Excel-based analysis tool.

MKXLSFUNC Example:

MKXLSFUNC Example:

Make a standard atmosphere function from an existing spreadsheet tool.

Contents

Create the m-file

The spreadsheet tool exists as troposphere.xls.

mkxlsfunc('tropos','troposphere.xls','C7:E8','C13:E15','',1);

The resulting m-file has a formatted help block:

help tropos
  TROPOS is a spreadsheet-calling function created using MKXLSFUNC.
    [rho, T, P] = tropos(h, dT)
 
    Inputs:
        h   - Altitude (m)
        dT  - Temperature offset (°K)
 
    Outputs:
        rho - Density (kg/m^3)
        T   - Temp (°K)
        P   - Press (Pa)
 
    See also MKXLSFUNC, XLSREAD, XLSWRITE.
 
    [rho, T, P] = tropos(h, dT)

Make a plot to check the function

h = linspace(0,11000,4);
rho = arrayfun(@tropos,h);

plot(rho,h,'-ok','LineWidth',2)
xlabel('Density (kg/m^3)')
ylabel('Altitude (m)')
title('Troposphere')

Call function with default values

Default values are the same as what is in the spreadsheet at the time of the first creation of the function.

[rho, T, P] = tropos
rho =

    1.2250


T =

  288.1500


P =

      101325

Remove file for future demos

delete('tropos.m')

Contact us