what does "V1MCC4000MEC1000MCR1000x" mean in matlab's .m file? - matlab

I have a problem with a .m file that I'm not able to read:
it starts as
V1MCC4000MEC1000MCR1000x
and that follow with many unreadable character like
漜哹逓馎(S煈KPO嘀菏戓N缻k?軥慍┎嘳鏴敕?簛ei?梤>?2;瀱啿唱煩烮?闑XSぜ时鷍徍頰r+燏p赠髬 <笉rVw拹p9_?=江秡?v
?R?RJ崀戓繝欴
What's wrong this .m file?
How could I transform it to the normal one?

Googling the string V1MCC4000MEC1000MCR1000x is enlightening. You may have not a .m source file, but a compiled executable on your hands.
Here's what Walter Robertson had to say about it:
The reference to MCR there suggests to me that what you have is not a
.m file but instead the result of running mcc to "compile" .m files (I
believe the output of that is a .exe file.)
But without further research I would not rule out the possibility that
it is a matlab .ctf (Component Technology File) or .p (p-code) file.
If you do, indeed, have a compiled .m file, there is no way to decompile it back to the original .m source.

Related

Add SPDX license information to .m Matlab files

What is the proper place to add SPDX license information to .m Matlab files?
In Matlab .m files are often written as functions with one (main) function per file.
Matlab interprets comments of functions as inline documentation.
If we simply write SPDX comments there, it will be rendered in the help information for the function.
https://de.mathworks.com/help/matlab/matlab_prog/add-help-for-your-program.html

Open and run a .m in matlab into an another .m file (from another directory)

I have a question about a code I am creating.
I have a code in a .m file, let's name it as "first.m".
But in the "first.m" i would like to write a command in this script in which I would like to run and execute an another .m file, let's name it "second.m" file, which is in a different directory.
I mean I would like to use a subroutine, but the main problem is that I do not have understand how can I use subroutines in MATLAB.
Could anyone help me to make it?
try coding using the run function.
It is important that Matlabs knows where to find that function. You can use the function addpath
Also, you can actually copy the full path in that command. Like this:
run('C:\Users\user\Desktop\second.m')
Make sure you write the correct path that contains second.m. If the code is in the same path as first.m or you have already added the path you can use:
run('second.m')
And if they are in a subfolder of the actual folder where first.m is, you can use the first example or:
run('subfolder\second.m')

How use pcode to regenerate a file in MatLab?

When I run a .m file containing a .p datafile I get the following error message:
The P-code file /Users/....
was generated prior to MATLAB version 7.5 (R2007b) and is no longer supported. Use pcode
to regenerate the file using MATLAB R2007b or later.
How should I use pcode to regenerate the file as suggested by the hint?
I try to type pcode filename and pcode(filename) but without any success. Any suggestions? Also I should mention that the .m does not work because of this problem so I cannot simply ignore the warning.
Pcode files are byte code translated matlab functions, which are heavily obfuscated during that process.
To solve this problem, you have to get the original m-function which was used to create the pcode file. It typically has the same file name with a different extension. Then you could run pcode again, or use the m-code.

Matlab Using .p file for compiling?

I m working on a Matlab project and I need UsbWebcams package for capture image from webcam. I can run .m file in matlab but when I compile project to create an exe file, My exe file return an error because usbWebcams package have some special .p files(Utility.p,webcamchannel.p etc) and I can not use these file for compiling.I searced on Internet and I didnt find any answer for this. How can I use .p files in my project. I think there should be a solution and I should find it. Thanks for helping to all.
Although MATLAB Compiler should be able to compile .p files, it's possible that the .p files you're trying to compile may have dependencies that you can't see because they're p-coded. For example, they might call an external library (this is quite possible if they are for interfacing with a webcam), or they might call another function using eval.
Whether they're .m files or .p files, if the files you're trying to compile have a dependency of this sort you need to include it explicitly for the Compiler, otherwise it won't know where to find it. But if the file is p-coded, it's tough to find out what the dependencies might be. You might need to ask MathWorks directly for support in compiling this functionality.

Search for pathway starting at directory of .m in Matlab

I'm trying to make a .m file that uses a .dll file and I want to be able to pass my script to other people without error. The only problem is that matlab always searches starting at the matlabroot or some drive if you specify. The location of the folder containing this project is going to vary depending on the user. So I can't simply use the function:
loadlibrary("C:\Users\Public\Documents\projectFolder\file.dll", "C:\Users\Public\Documents\projectFolder\file.h")
in my .m file assuming that every user has the project folder in "C:\Users\Public\Documents".
I'm trying to see if there's a way for matlab to just know where the .m file is and start at that path, then maybe I could set the code up like this:
path = [some code which finds the path of .m file];
loadlibrary(strcat(path, 'file.dll'), strcat(path, 'file.h'));
Thanks
MATLAB requires any .m file to be in its search path before it will run it (I don't think that's strictly true, but it will complain mightily if it isn't). Users can add and/or subtract directories from their path pretty easily, and so it's a safe assumption that if the user has installed your script, they've put it somewhere in their MATLAB path. If they haven't, and they try to run it, MATLAB will pop up a dialog warning that the script is not in the path and asking if they would like to temporarily add it.
As to how to find it and how to use that information, you'd do something like this:
scriptLocation = mfilename('fullpath');
[directory,name,extension] = fileparts(scriptLocation);
dllLocation = fullfile(directory,[name '.dll']);
headerLocation = fullfile(directory,[name '.h]);
loadlibrary(dllLocation, headerLocation);