On this page I found an interesting implementation for fingerprinting of digital pictures. It is written in MATLAB, therefore I downloaded GNU Octave and tried to run the example.
But I get the error
'mdwt' undefined near line 47 column 14
error: called from 'NoiseExtract' in file C:/Users/......../CameraFingerprint/Functions\NoiseExtract.m
near line 47, column 12
There is a hint on the webpage above:
Q: Do I need any additional packages or libraries?
A: You need discrete wavelet transforms such as those included in
\Filter directory as dll (developed by Markus Lang from Rice
University). These .dll run under 32-bit Windows only. You may need to
recompile them uder your operating system if different.
So I got the .dll-Files, but how do I use them and the functions inside?
Related
I am using a MATLAB m file code which loads a simulink file, runs it and evaluats it so many times inside a complicated parallel loop.
It runs perfect at MATLAB environment. When compiling the code via deploytool command, installing it and running it from command line, I would have a difficult time.
At the line where it is loading the model,
mymodel= ... ;
load_system(mymodel);
I get the following error
C:\Program Files\mymain\application>Warning: Name is nonexistent or not a directory: model
> In path at 109
In addpath at 86
In run_main at 3
Warning: Name is nonexistent or not a directory: data
> In path at 109
In addpath at 86
In run_main at 4
Warning: Name is nonexistent or not a directory: graphics
> In path at 109
In addpath at 86
In run_main at 5
Starting parallel pool (parpool) using the 'local' profile ... connected to 2 workers.
Initializing ...
Undefined function 'load_system' for input arguments of type 'char'.
Error in run_main (line 40)
MATLAB:UndefinedFunction
I don't care about warnings (as I don't care about most of other MATLAB warnings) however I get error about not recognizing function to open a simulink model ('load_system') :
Undefined function 'load_system' for input arguments of type 'char'.
I did a search and I found the following questions:
load_system using MCR
Deployment of Simulink Models
The first link says
I just got confused: is deployment tools about compiling to C++ or to .NET ?
Is is supposed to increase speed or becomming stand-alone is the only advantage?
The problem with both links is that they talk about strategy. But how to implement them? How can I compile a MATLAB code which uses load_system and sim command to load and simulate a model?
Can anybody bring step by step solution for a very simple example of a MATLAB code (m file) simulating a model and then compiling both of them?
The first sentence of your documentation screen shot is the important one. As mentioned by #Navan (in a comment), Simulink functionality is not compatible with MATLAB Compiler. That is, any m-code that uses Simulink functinality (load_system, sim, etc) will not execute when using the MATLAB Compiler.
Assuming that you have access to Simulink Coder, and that your model doesn't contain functionality that prevents it from being converted to c-code, then your only option is to develop your application in two parts:
With your Simulink model: Use Simulink Coder to create an executable from your model. There are several examples of doing this in the doc, including Using RSIM Target for Batch Simulations. There are various command line options for passing new parameter sets and inputs to the executable via a mat file. The results of the simulation (i.e what would normally be written to the MATLAB Workspace) gets written to a mat file created by the executable.
Within you MATLAB code: replace all Simulink functionality with a call (typically using the system function, as shown in the linked example) to the executable created in step 1. Prior to this call you'll need to create a mat file with all your parameters in it; and after the call you'll want to read results from the mat file created by the executable.
It's not a trivial process, but is do-able.
I have just installed PottersWheel (latest version) for Matlab (version R2014a) on 64-bit machine. When attempting to use the 'New Model' button I get an error which I have pasted below:
-------------------------------------------
Problem detected at 2014-10-17 14:06:01:
Attempt to reference field of non-structure array.
Line 128 of pwGetFieldWidths.p
Line 170 of pwModel2CellArray.p
Line 126 of pwSaveModel.p
Line 607 of pwCreateModelGUI.p
Line 175 of pwCreateModelGUI.p
Line 95 of gui_mainfcn.m
Line 60 of pwCreateModelGUI.p
Matlab 2014a (mexw64) PottersWheel 3.1.0
-------------------------------------------
Since apparently there is no way to access .p files as they are protected. Does anybody know how to fix this problem?
The .p files are obfuscated MATLAB functions (or kind of object files). So, you cannot edit them. The possibilities are:
You read the documentation carefully, and verify that your arguments obey the requirements;
If #1 fails, you contact the author that holds the source and ask him/her for advice and bug fixing.
If #2 fails, you look for an de-obfucscator/de-compiler.
The executable is created by using mex. Currently I tried it on windows, but eventually I will need it for windows, linux, and mac os x.
The problem is it can only be used with the same version of matlab which I used to create it.
The main reason I think is if different version of matlab is used, then the path for libraries used by the executable will be different.
Is there any way that I can create an executable from mex which can be compatible with different versions of matlab?
Is possible that I set paths for libraries and header files associated with multiple versions of matlab?
Please correct me if I understand anything wrong above. Thanks a lot.
More detail information:
The way to generate my executable is to call:
mex('-v', '-f', [matlabroot '\bin\win32\mexopts\msvc90engmatopts.bat'], 'myexecutable.cpp');
In the msvc90engmatopts.bat file, paths are set for librarires and header files and etc.
msvc90engmatopts.bat is from matlab.
I just bought the student version of Matlab 2013. I have three well log files (.las) and I have downloaded them onto my computer.
When I open matlab I think it has to deal with either retrieving the .las file, or setting the path to get the functions. When I try to even type help readlas it gives me this error:
"Undefined function 'readlas' for input arguments of type 'char'."
Where do I set my path? How do I let Matlab access those three well log .las files?
MATLAB does not have any built-in capability to read LAS well log files. There is no function readlas supplied with MATLAB. If you have a program that uses a command readlas, you will need to contact the author of the program to obtain the code for readlas, and then add the directory containing readlas to your path. If you already have readlas, then just add its directory to the path.
There are freely available third-party tools that can read LAS files into MATLAB - one of the most common is Seislab, available here from the MATLAB Central File Exchange. However:
It's likely that the way Seislab reads in LAS data differs from the way your readlas reads it in, and I would doubt that you can simply replace your readlas with Seislab's read_las_file without changing quite a few other things.
Seislab is in general a horrible piece of software that I do not recommend you use unless you really have to.
Hope that helps!
Installing Matlab toolboxes
This looks to be a question about how to install a Matlab toolbox so that Matlab can find it. These look like the relavant links
how to install a toolbox to matlab if I do not have administrative authorization
How to install toolbox for MATLAB
How do I add a new toolbox to my already installed Matlab version?
Matlab tools to read LAS (Log-Ascii-Standard) files.
Readlas
readlas looks to be part of CREWES Matlab toolbox:
https://www.crewes.org/ResearchLinks/FreeSoftware/
Description
https://www.crewes.org/ForOurSponsors/ResearchReports/2013/CRR201331.pdf
The CREWES Matlab toolbox contains a script called readlas that has long had the ability to read version 1.2 and version 2.0 Log ASCII Standard (LAS) files. A new Matlab class called las that can handle all LAS versions has been written. The constructor reads an entire LAS file into memory and splits it into a Matlab cell string array using regular expressions. The readlas script is now a wrapper that creates a new las object and returns version 2.0 inputs suitable for logedit and syngram regardless of the LAS version of the input file. Since logedit and syngram cannot handle the multiple log data sections or logs containing character data (eg. lithology) that are allowed in LAS 3.0 files, or more than ten logs effectively, readlas provides graphical user interface (GUI) windows that prompt users to pick which log data section they would like to work on, and decide which logs within that section they want to edit. It also replaces any log character data with log null (numeric) values. The original readlas (pre 2013) is still available in the toolbox as readlas_old.
Las Toolbox
https://github.com/MosGeo/LasToolbox
A LAS file format toolbox for reading Las files in Matlab. All
information is loaded in a structured format including headers.
Currently, the code can only be used with LAS version 2. LAS version 3
is not currently supported.
I was wondering if there is a way to create a '.exe' file from ' .m' file in MATLAB, such that it can be run in machine which does not have MATLAB (like it can be done in C, C++).
I know writing a MATLAB function is one way, but I am not sure if it can run in machine without MATLAB.
Also I would like to hide my code and just create a script which can be run by a user using his own data files.
The Matlab Compiler is the standard way to do this. mcc is the command. The Matlab Runtime is required to run the programs; I'm not sure if it can be directly integrated with the executable or not.
If you have MATLAB Compiler installed, there's a GUI option for compiling. Try entering
deploytool
in the command line. Mathworks does a pretty good job documenting how to use it in this video tutorial: http://www.mathworks.com/products/demos/compiler/deploytool/index.html
Also, if you want to include user input such as choosing a file or directory, look into
uigetfile % or uigetdir if you need every file in a directory
for use in conjunction with
guide
Try:
mcc -m yourfile
Also see help mcc
If your code is more of a data analysis routine (vs. visualization / GUI), try GNU Octave. It's free and many of its functions are compatible with MATLAB. (Not 100% but maybe 99.5%.)
mcc -?
explains that the syntax to make *.exe (Standalone Application) with *.m is:
mcc -m <matlabFile.m>
For example:
mcc -m file.m
will create file.exe in the curent directory.
It used to be possible to compile Matlab to C with older versions of Matlab. Check out other tools that Matlab comes with.
Newest Matlab code can be exported as a Java's jar or a .Net Dll, etc. You can then write an executable against that library - it will be obfuscated by the way. The users will have to install a freely available Matlab Runtime.
Like others mentioned, mcc / mcc.exe is what you want to convert matlab code to C code.
The "StandAlone" method to compile .m file (or files) requires a set of Matlab published library (.dll) files on a target (non-Matlab) platform to allow execution of the compiler generated .exe.
Check MATLAB main site for their compiler products and their limitations.
I developed a non-matlab software for direct compilation of m-files (TMC Compiler). This is an open-source converter of m-files projects to C. The compiler produces the C code that may be linked with provided open-source run-time library to produce a stand-alone application. The library implements a set of build-in functions; the linear-algebra operations use LAPACK code. It is possible to expand the set of the build-in functions by custom implementation as described in the documentation.