Be the first to rate this file! 13 Downloads (last 30 days) File Size: 10.56 KB File ID: #32507

MSPA

by Anders Lennartsson

 

11 Aug 2011 (Updated 23 Aug 2011)

A mex interface function to the C function spa.c developed by NREL for computing solar position.

| Watch this File

File Information
Description

The MATLAB function mspa is a mex interface function to the C function spa.c developed by National Renewable Energy Laboratory (NREL) for accurately computing the position of the sun on the sky.

The algorithm on which the reference implementation spa.c is based is described in the report "Solar position algorithm for solar radiation application" by Ibrahim Reda and Afshin Andreas, National Renewable Energy Laboratory (NREL) Technical report NREL/TP-560-34302, Revised January 2008.

The report is available from
http://rredc.nrel.gov/solar/codesandalgorithms/spa/
There is also a link from which the reference implementation spa.c and a corresponding spa.h file can be downloaded.

Once the zip-file in this submission is unpacked and the files spa.c and spa.h downloaded to the same directory, the mex interface function can be compiled with mex mspa.c spa.c

The calling syntax of mspa is
res = mspa( arg )
where arg is a column vector with 17 rows containing the arguments to the function spa.c, and res is a column vector containing the results of the function spa. The ordering of individual parameters in the argument follows the one described in the report, look at the file mspa_tester.m for details.

A valid argument arg can also hold multiple columns, i.e. it can be a 17 x n matrix where n > 1. If so, the result is also a matrix with equally many columns and each column of the result holds the result of the function spa evaluated for the corresponding column of the argument matrix.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
sun_position.m

MATLAB release MATLAB 7.9 (2009b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
23 Aug 2011

.

Tag Activity for this File
Tag Applied By Date/Time
astronomy Anders Lennartsson 23 Aug 2011 13:08:02
solar energy Anders Lennartsson 23 Aug 2011 13:08:02

Contact us at files@mathworks.com