Why does my compiler not recognize dataset variables.

3 views (last 30 days)
Dear Matlabeers, I am using the MATLAB compiler to create a standalone application and collaborate with my friend.
I have created a function to calculate a risk score, and I am using datasets to store the variables.
I can run the function in my computer, and I can compile it and run it through my compiler. However, it won't run in my friend's compiler, who in fact has the same version as I do. The error that I get is:
Attempt to reference field of non-structure array.
MATLAB:nonStrucReference
Would anyone know how to solve this? By the way, I'm using a previous version R2012b.
A part of my code that contains the problem is:
%%Inherited variables: sqlScript, connection, appId, metadata, threshold
function score = zeroOneScore()
% SQLSCRIPT defines procedure THUMB_AND_BALANCE.
runsqlscript(connection, sqlScript);
cursor = fetch(exec(connection, ...
sprintf('CALL THUMB_AND_BALANCE(%d)',appId)));
dataset_ = cursor.Data;
close(cursor);
%%Print for verification.
fprintf(['Data from SQL query THUMB_AND_BALANCE is of class %s ' ...
'and size [%s].\n'], class(dataset_), num2str(size(dataset_)));
% Discard if there's no data.
if strcmp('No Data', dataset_)
fprintf('Application with ID %4d stored no data.\n', appId);
score = nan;
return
end
%%------------------------------------------------------------------------
% PROCESS, PARSE AND FILTER THE DATA
% ------------------------------------------------------------------------
% Apply the rule of thumb.
payment = dataset_.PAYMENT_; %%%%%%%%%%THIS IS WHERE IT BREAKS.
income1 = dataset_.NET_INCOME_;
income2 = dataset_.SALARY_ID;
income3 = dataset_.HOUSEHOLD_SALARY_ID;
incomes = [income1, income2, income3];
% userCapacity = finclDS.PAYMENT_CAPACITY_;
capacityIdx = payment./incomes;
if all(capacityIdx <= threshold)
r_thumb = 2;
elseif any(capacityIdx <= threshold) && ...
any(capacityIdx > threshold)
r_thumb = 1;
elseif all(capacityIdx > threshold)
r_thumb = -1;
end
dataset_.CAPACITY_RULE_ = r_thumb;
% Also reject application if it has negative ones in key positions.
minusOneVars = metadata(metadata.MinusOne, :).Name;
% incomplete = dataset_(:,minusOneVars) == -1;
incomplete = datasetfun(@(var_)(var_ == -1), dataset_, ...
'DataVars', minusOneVars, 'UniformOutput', false);
incomplete = all(cell2mat(incomplete),2);
if r_thumb == -1 || incomplete
fprintf('Application''s user with ID %4d doesn''t show capacity of payment.\n', ...
appId);
score = 0; % Arbitrary zero.
return
end
score = performOperations(dataset_, metadata);
return
% =====================================================================
end
return
% =========================================================================
end
  2 Comments
Image Analyst
Image Analyst on 9 Sep 2014
You forgot to copy the entire error message. You did like so many others do and that is to just snip out a tiny portion of the full error message and expect us to know what caused the error without seeing the code. Please at least copy all the red error text (code, line numbers, error message - everything in red ), and you should probably also attach the full m-file.
Andrea Villamil
Andrea Villamil on 9 Sep 2014
I have attached the function for the code, although I cannot attach the whole error as I'm running it through the Compiler.
Strange thing is that it runs well on my computer and with my compiler. Thanks.

Sign in to comment.

Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!