How to generate a binary executable file for my matlab functions so that other users can just compile this binary file and use it without looking at matlab code?
7 次查看(过去 30 天)
显示 更早的评论
Hi, I got a question here. I wrote a function in matlab. This function needs multiple inputs. Inside the function, it also to read two .txt files for parameterization. I am trying to compile this function and these two parameter files into one binary file, so for others who want to use this function, they only need to upload this binary file into their matlab library, and then compile it and use it, without looking at the original code. Does anybody have any idea about how to do this? Thank you very much! Here is some code about my function:
%input data array: sst, Rrs412, Rrs443, Rrs488,Rrs55, Rrs667
%output data array:SSS
%function begins
function SSS...
= sss_MODIS_aNN(sst,Rrs412,Rrs443,Rrs488,Rrs555,Rrs667,I)
%import parameter files (totally there are 4 files)
Bias_In_I=importdata('b1_br_gom.mat');
Bias_Out_I=importdata('b2_br_gom.mat');
Weight_In_I=importdata('matlab_nn/w1_br_gom.mat');
Weight_Out_I=importdata('w2_br_gom.mat');
%make the input data array ready
Input_I=[nsst,nRrs412,nRrs443,nRrs488,nRrs555,nRrs667]';
%now calculate the output
n_I=Weight_In_I*Input_I+Bias_In_I*ones(1,length(Input_I(1,:)));
activation_function_I=2./(1+exp(-2.*n_I))-1;
output_I=Weight_Out_I*activation_function_I+Bias_Out_I*ones(1,length(Input_I(1,:)));
out_I_a=(Sigma_Out_I(1)*(output_I)+Mean_Out_I(1));
SSS=out_I_a(1,:);
%output has been derived
0 个评论
采纳的回答
Walter Roberson
2017-1-25
MATLAB Compiler SDK can compile into a routine that can be called from MATLAB.
Is there a particular reason that you are using importdata() with a .mat file instead of using load() ?
I recommend that you put in statements to test that the mat files are present and that the data import succeeds.
The routine does not seem to be very complicated; is there a reason to hide the code?
If the idea is not hiding the code, and is instead just bundling everything together, perhaps all you need is to Package an App
3 个评论
Walter Roberson
2017-1-25
If I understand correctly, MATLAB Compiler SDK will add the .mat files to the project and compile them in. I could be wrong on that point as I do not read as much about Compiler SDK. (I do not have the product myself.)
Your arrays appear to be numeric. Have you considered using save -ASCII or using mat2str() to write the numeric arrays into .m files that you can then "call" to initialize your data. You can be sure that the library that was built would include the data then.
For that matter, you could use mat2str() etc. to create one single .m file that you could then hand to your users.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Troubleshooting in MATLAB Compiler SDK 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!