How to pass a class to MATLAB executable
Show older comments
I have the following script
main.m >>
function m = magicsquare
n = setting.n;
if ischar(n)
n=str2double(n);
end
m = magic(n);
disp(m)
and a class from which the variable n is read by the above script.
classdef setting
%SETTING Summary of this class goes here
% Detailed explanation goes here
properties(Constant)
n = 5;
end
% methods
% function obj = setting(inputArg1,inputArg2)
% %SETTING Construct an instance of this class
% % Detailed explanation goes here
% obj.Property1 = inputArg1 + inputArg2;
% end
%
% function outputArg = method1(obj,inputArg)
% %METHOD1 Summary of this method goes here
% % Detailed explanation goes here
% outputArg = obj.Property1 + inputArg;
% end
% end
end
I have converted main.m into a executable using the Application compiler. Since I want the user to specify input in `setting` class, this class was not converted into a binary during compilation (i.e. I have excluded the setting.m file from `Files required for your application to run` tab in the Application compiler.)
Here is what I tried: I simply saved main.exe and setting.m class in the same folder and ran !main.
I get the following error
Unable to resolve the name setting.n.
Error in main (line 2)
MATLAB:undefinedVarOrClass
I could have passed `n` as an input argument to the executable like mentioned in my previous post since `n` is a single property defined in setting class. However for my real system , there are more properties defined in settings and I want the user to define all the properties in a single class file from which the rest of functions can access the property values defined. I am not sure how to pass a class to the `main` executable. Suggestions will be really helpful.
Accepted Answer
More Answers (0)
Categories
Find more on Performance and Memory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!