How to lock MATLAB files keeping them executable - matlab

How to lock MATLAB files keeping them executable.
I am writing code to create GUI where third party should run the .fig file but should be unable to read the code written. Main GUI editor file contains user defined functions also, where they should be locked too with capability of execution.
Thank you in advance.

You can p-code your MATLAB functions:
http://www.mathworks.co.uk/help/matlab/matlab_prog/protect-your-source-code.html

Related

Simulink executable is not reading .mat files

I have a Simulink model wihich reads some data from a .mat file using a "From File" block. For ilustration's sake I created the following simple system which has the same problem I'm experiencing with my original model:
I need to generate a C code to run the model on another PC that does not have MATLAB. I generated the code and compiled it to validate it and I noticed that the executable is not reading the .mat file. No matter what signal I put on the file, the executable runs the model using the signal available at the moment of the compilation. I even erased the .mat file and the executable ran normally. Why is this happening? it is supposed that the "From File" block is there to read a .mat file, but it is not fulfilling its purpose.
NOTE: I am using MATLAB R2012b and Simulink version 8.0. I am using the Embedded Coder target (ert.tlc) for the code generation. I tried using the Rapid Simulation target (rsim.tlc) and the executable worked properly, however the execution time was higher. So I want to find a way to use the Embedded Coder target to have a lower execution time.

Double-clicking to open a file on a standalone matlab application

I have timeseries files with their own extension (.Z4R). I have compile my matlab GUI that read them.
Right now I load these files from the GUI (look for the path...). I wondering if it's possible to just double-click on the .Z4R in order to load it into my program.
Thank you.
I understand the window part.
Where I don't know it is about this command line that accept the input (Z4D) when the GUI .exe starts. How do I know the path of the double-clicked file.
Thanks
Marc
You should be able to do this via Windows file association (assuming you are running windows).
You'll need to check the command line arguments of your app and open supplied Z4R files as appropriate.
Have a look on google to see how to set-up file associations
If your compiled Matlab GUI was created using the Matlab tool guide, you should have a function
function YourProgramName_OpeningFcn(hObject, eventdata, handles, varargin)
varargin should contain the filename you double clicked on.

How can I search in my computer for some txt files inside GUI?

I am using the Matlab Guide function in order to build an inteface with the user. Nevertheless, I need to read some arrays that are in 5 different txt files. I would like to run my guide application, and using any command, start to search my computer and load these .txt files into my program. How could I easily do it?
Thanks in advance for your help.
I don't believe that there is a built-in function that will do that for you, so either you have to loop through some dir commands yourself or grab a file from MATLAB Central / File Exchange: e.g. DIRR or subdir.

Opening .m files DIRECTLY in MATLAB

I am using Ubuntu 10.04 and have MATLAB installed on my computer. I wanted to know if there was any way to open .m file directly in MATLAB without having to go through the painful process of starting MATLAB, and navigating through folders to open up desired scripts.
Try changing file associations for .m files so that you can double click on them and have them open in the MATLAB editor.
A startup file for user-defined options may fit your needs. Or have a look at shortcuts by Mike.
To open an m-file from matlab w/o navigating through menus:
>>edit myfile
The extension .m is assumed. This requires that myfile.m is in matlab's search path.
To add your favorite locations to matlab's search path, try
>>pathtool
and choose SAVE so the locations are preserved for your next Matlab session.
What worked for me is appending %F to the end of Exec=some/path which is in my matlab.desktop file.
Locate the matlab.desktop file its either in ~/.local/share/applications or ~/usr/share/applications.
Solution from here
Also if you don't have a matlab.desktop file then you may want to create one link to some relevant help to create launcher icon

How to set some custom variables on Matlab startup

I would like to set some initial variables (like format compact and the current directory) automatically on each startup of Matlab.
How can I do that?
Create a startup.m script file containing the commands to set up the state that you want. Next, from inside MATLAB, run the command
>> userpath
This will give you a list of one or more user-specific directories (depending on what OS you are using); put your startup.m in any of those directories and it will be found whenever you start MATLAB (startup.m is also found if it is in the directory from which MATLAB is started, but the technique above allows you to start MATLAB from an arbitrary directory and still have startup.m get run).
Create a startup.m file in the directory that you launch matlab from.