spaceconcordia / rocketry-performance

2 stars 1 forks source link

Can't read array from workspace in Matlab Function Block - Subscripting mxArray issue #3

Closed SpaceShawn closed 8 years ago

SpaceShawn commented 8 years ago

Error when attempting to read from the Matlab Workspace in a Matlab Function block in Simulink

coder.extrinsic('evalin');
thrust_curve_len = evalin('base','thrust_curve_len');
thrust_curve = zeros(thrust_curve_len,2,'double');
thrust_curve = evalin('base','thrust_curve');

% grab the size of the input thrust curve
data_length = size(thrust_curve,1);

% create the corresponding weight curve, same size
weight = zeros(data_length,1);

weight = wet_motor_weight(:) - wfc*thrust_curve(:,1);

Error Message:

Subscripting into an mxArray is not supported.

Function 'Thurst Curve Data/MATLAB Function' (#24.1194.1211), line 29, column 36:
"thrust_curve(:,1)"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder error

The following resource explains that data must be preallocated http://www.mathworks.com/matlabcentral/answers/13297-subscripting-into-an-mxarray

However it is clear in the code above that this step has been taken.

SpaceShawn commented 8 years ago

Got around this by using the From File block