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.
Related
I saved my command line by first clicking on it and pressing ctrl+s and MATLAB saves a .mat file.
Now I want to open it in a text form in order to remember what I did in my command line the other day.
Is there a way to do that?
Saving a .mat file from the command window saves all of the variables that currently exist within your workspace within a binary .mat file. There is no information about the commands that were used to generate these variables in this file format therefore it cannot be automatically extracted from another program.
If you need to get information about what commands were run, you can look at your command history to see this. If you need to programmatically access this file you can look in MATLAB's preference directory for the file named history.m or history.xml on newer versions.
type(fullfile(prefdir, 'history.m'))
If you need to keep track of what commands you run in the future, you can use diary at the top of your script or beginning of your session to log all commands and associated command line output to a plain-text log file which would then be accessible to other programs.
diary('mylogfile.txt')
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
I'm getting message
Error in S-function 'project1_simu/S-Function': S-Function 'chiu_sfcn' does not exist
whenever i run my simulink file which contains s-function block diagram. Any tips to resolving this problem?
You need to compile the s function using mex.
Then the mex32 output file needs to be on the matlab path.
For an S-Function, you need to make sure your C, Matlab, or Fortran Code is where Simulink expects it to be. My guess is your code exists, but isn't in the directory simulink expects.
Right click on the S-Function Block in your Simulink Project -> Choose S-Function Parameters.
Click on the Edit button next to the S-function name.
It will probably tell you the S-Function source cannot be found. It will then prompt you to either browse for the code or open an editor.
If you can't figure out where this file is located and you have the code your best bet is to open the Editor from this dialog box.
From there just paste the code and save it as 'chiu_sfcn'. You don't need to put a file extension, or browse to a different folder. It should automatically save it in the right folder for you.
It is possible that your version of Matlab is newer
than the version of Matlab used to produce the S-function.
If this is the case, I believe that the S-function
must be recreated in a newer version of Matlab
in order to interface with newer versions of 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
We all know MATLAB provides tab-completion for filenames used as arguments in MATLAB function like importdata,imread. How do we do that for the functions we create?
EDIT:
Displays the files and folders in the current directory.
Caution: unsupported hack here.
Take a look at the file toolbox\local\TC.xml in your Matlab installation. This appears to contain the argument type mappings for tab completion. (I found this by just grepping the Matlab installation for "imread" in R2009b.)
Adding this line inside the <TC> element will get you tab-completion of file names for each of its arguments.
<binding name="importdata" ctype="FILE"/>
This requires modifying the Matlab installation in place. For some of the other files in toolbox/local, like classpath.txt, you can override them by placing modified copies in the directory you start Matlab from, but this didn't work for TC.xml for me.
There is no supported way to add your functions to the argument Tab completion, but one trick I use is to put a "!" in front of the command so it is treated like a system command. Tab will then complete file paths. Once my MATLAB command is done, I home to the beginning of the line, delete the "!" and press enter.
For Matlab 2016a and above :
The file Tc.xml is not present in Matlab 2016a onwards. It uses a .json (Java Script Object Notation) file to achieve the same. A simple example of this can be as follows.
Suppose you have a Matlab function file called myFunction.m. Furthermore, suppose that this function needs files with extension .ext as input and you want the tab-completion to show all possible input options for this function. Then, write the following content in a file and name it functionSignatures.json.
{
"myFunction":
{
"inputs":
[
{"name":"filename", "kind":"required", "type":"filepath=*.ext" }
]
}
}
Place this file in the same directory as myFunction.m file. Now, restart Matlab.
What this file does : While typing in the function input, upon pressing tab, you will see a list of files with the extension .ext popping up. If you want all the files to be shown in tab completion popup irrespective of their extension, then replace "type":"filepath=*.ext" with "type":"filepath" in the file functionSignatures.json.
Source : https://www.mathworks.com/matlabcentral/answers/306157-how-to-configure-tab-completion-for-my-function-in-matlab-2016#answer_237857