spaceconcordia / rocketry-performance

2 stars 1 forks source link

Can't pass csv data to multi-dimensional array in Simulink Matlab Function #2

Closed SpaceShawn closed 9 years ago

SpaceShawn commented 9 years ago

When running _thrust_dataimport.m as a Simulink Matlab Function, an error is thrown.

thrust_data_import.m

function thrust_curve = thrust_data_import()
%-------------------------------------------------------------------------------
%
% thrust_data_import.m
%
% Data Access of Parametric Model
%
% Thrust curves are provided in tabulated and time-based form. The values for 
% thrust need to be processed as input to the model in a synchronized fashion
% with the simulation clock
%
% A csvfilename shall be provided for a CSV file containing in the first column
% the time and in the secoond column the thrust force
%
% The data is read using xlsread and transposed for a lookup table to change
% the data
% 
% TODO The data should be interpolated to keep the time-step constant
% 
% Important Notes:
% Time values need to be monotomically non-decreasing. Meaning, the time
% step must be equal or increasing only. As such, the smallest time-step
% should be chosen and the data in between interpolated to complete the 
% set. TODO
%
%-------------------------------------------------------------------------------
% References
% http://www.mathworks.com/help/simulink/ug/how-to-import-data-from-an-excel-spreadsheet.html
% http://www.mathworks.com/help/matlab/matlab_external/example-reading-excel-spreadsheet-data.html
%-------------------------------------------------------------------------------

coder.extrinsic('xlsread');

% Import the data from Excel
% data = xlsread(csvfilename);

% TODO hardcoding is bad
data = xlsread('monotomic_time_thrust_curve.csv');

% TODO Interpolate the data
% data = scrd_interpolate(data)

% instatiate the output container
thrust_curve = zeros( size(data) );
double(thrust_curve);

% store the thrust curve in the workspace
thrust_curve = data

Error Message:

Function output 'thrust_curve' cannot be an mxArray in this context. Consider preinitializing the output variable with a known type.

Function 'Propulsion Input Data/MATLAB Function' (#40.9.21), line 1, column 10:
"thrust_curve"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder errorOpen

 Errors occurred during parsing of MATLAB function 'Propulsion Input
Data/MATLAB Function'(#39)
Component: MATLAB Function | Category: Coder error

 Errors occurred during parsing of MATLAB function 'Propulsion Input
Data/MATLAB Function'(#39)
Component: Simulink | Category: Block error
SpaceShawn commented 9 years ago

Duplicate of #3