matlab scripts conversion to C/java or .exe
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi Is it possible to convert matlab script (NOT MATLAB FUNCTION)to C/java code? 1. Suppose I have written a matlab function without any input parameters. It calls excel file (using uigetfile) and read the data from the file, do some simple processing and writes the output again to a xls file using xlswrite. Can I generate the C/java code for this using matlab coder or .exe file using deploytool?
Sample code could look like this: function processdata file = uigetdir; data = xlsread(file); data(:,1) = data(:,1)+1;
xlswrite('outdata.xlsx' data(:,1));
2. I have gone through mathworks products and webinar on code generation. Most of the time I came across that they talk about converting a matlab function to C/C++/java code. What if I have script which calls some in-built as well as new matlab functions, can that be converted to C code?
Example: ( test_script.m) %% script start data = xlsread('test1.xls');
avg = mean(data);
vari = var(data);
% new function processdata; % defined above
parameter_store = data_shift(avg,vari); % another m function which takes avg and vari as input and gives some output %% script end Is there a way that above mentioned test_script.m can be converted to C/java code or deployed as application (.exe)?
regards Prashant
0 Commenti
Risposte (2)
Walter Roberson
il 12 Dic 2011
If you have a new enough version of the MATLAB Compiler, it can compile scripts . I am not certain which version it was that this became available, but I think it was R2010b .
Note that the process of compiling the script is to pretty much wrap it in a function with no arguments.
Is there a particular reason why it is important that it be a script that is compiled? Could you not create a function that invoked the script and then compile that function?
I do not know if JA Builder can handle scripts; a post I saw a week or two ago was suggestive that it could not handle scripts, but I might have misunderstood what I was reading.
0 Commenti
Prashant bajpayee
il 12 Dic 2011
1 Commento
Walter Roberson
il 12 Dic 2011
In order for xlswrite() to be able to output .xlsx files, the software must be run under MS Windows, and a compatible version of Excel must be installed on the system it is running on. If you run under any other operating system or run on a system that does not have Excel installed, xlswrite() can only write CSV files.
I suggest putting a try/catch block around the xlswrite(), as I suspect you are getting an error generated at that point.
I just looked back through the release notes, and I checked documentation, and it appears that compiling scripts is still not supported. I thought I had seen postings indicating otherwise, but I cannot find those so the documentation that says NO should be considered as the correct answer.
deploytool invokes the MATLAB Compiler.
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB Compiler SDK in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!