Extract .mat data without matlab - tried scilab unsuccessfully - matlab

I've downloaded a data set that I am interested in. However, it is in .mat format and I do not have access to Matlab.
I've done some googling and it says I can open it in SciLab.
I tried a few things, but I haven't found any good tutorials on this.
I did
fd = matfile_open("file.mat")
matfile_listvar(fd)
and that prints out the filename without the extension. I tried
var1 = matfile_varreadnext(fd)
and that just gives me "var1 = "
I don't really know how the data is organized. The repository described the data it contains, but not how it is organized.
So, my question is, what am I doing wrong in extracting/viewing this data? I'm not committed to SciLab, if there is a better tool for this I am open to that.

One options is to use Octave, which can read .mat files and run most Matlab .m files. Octave is open source with binaries available for Linux, Mac, and Windows. Inside of Octave you can load the file using:
load file
See Octave's manual section 14.1.3 Simple File I/O for more details.

In Scilab:
loadmatfile('file.mat');
(Source)

I had this same interest a few years back. I used this question as a guide. It uses Python and SciPy. There are options for NumPy and hd5f as well. Another option is to write your own reader for the .mat format in whatever language you need. Here is the link to the mat file format definition.

Related

Where are matlab files stored which are given in documentation for trying out in browser

I have used try in browser features in matlab to run some code which are the part of documentation provided by matlab.
To explain this more simple, here is the link which lets users to try the matlab in browser.
I am trying to see those matlab files ( object3d.mat) in this case. But I cannot find any information about where are those files.
Is there anyway to download that file ('object3d.mat) ?
These mat-files come with MATLAB installation. If the MATLAB directory (including all sub-directories and files) is in your path (by default, it is) then you can use load to load it into your workspace i.e.
load object3d.mat
%or just: load object3d
If it is in your path, you can know its location using which i.e.
>> which object3d.mat
C:\Program Files\MATLAB\R2018a\toolbox\vision\visiondata\object3d.mat
>>
Note: Please make sure that you're reading the documentation of your installed MATLAB version and have the specific toolbox installed. If the documentation for the MATLAB version that you're using doesn't include that filename then it is likely that it is not available in that version.

How to convert las file to ply file?

I want to open my 3D point cloud in MATLAB. But they are in .las files. How can I display them in MATLAB???
I heard about .ply file can open 3D point data on MATLAB. So I want to know how to convert las files to ply files.
There is a .las file reader for matlab here:
https://es.mathworks.com/matlabcentral/fileexchange/48073-lasdata
Once you have the data in matlab you can use these point cloud tools, which are part of the computer vision toolbox:
https://es.mathworks.com/help/vision/3-d-point-cloud-processing.html
If you want to embrace the open source force, I'm writing a Python (easy transition from matlab) library for point cloud processing:
https://github.com/daavoo/pyntcloud
You can use the free and open-source CloudCompare software.
On the command line:
CloudCompare -O file_to_convert.las -C_EXPORT_FMT PLY -SAVE_CLOUDS
Take care to the order of the options: it seems that -SAVE_CLOUDS must be at the end.
That will result in a binary-format PLY file in the same directory as the file to convert, named using the original filename and the date of export, like: file_to_convert_2019-07-18_13h32_06_751.ply
I found no way to specify the output file name (should you find one please comment below).
Should you want a more predictable name, add option -NO_TIMESTAMP before the option -SAVE_CLOUDS (but then you risk overwriting files so be careful).
More help (such as how to export in ASCII-format) in the documentation.
I timed this on powerful PC, it took 170s to convert a 2.7GB LAS file with 102M points (XYZ,intensity,time).
if you have LAStools installed, you can use las2txt to convert your *.las/*.laz files into *.xyz format which MeshLab can import natively as a point cloud, which may then be converted into a Mesh.
There are a multitude of caveats to that depending on the source of your data-set.

How to edit "mexopt.bat" file in Matlab?

I have Matlab R2014b and OpenCV 2.4, i have been trying to use ViolaJones Face Detection toolbox, but i have some troubles. I've searhced the problem and found a solution that suggest edit mexopt.bat file. What the real problem is here
The Matlab command
fullfile(prefdir, 'mexopts.bat')
returns
C:\Users\simit\AppData\Roaming\MathWorks\MATLAB\R2014b\mexopts.bat
but I can't find the file when I go to the path. How can I find the mexopts.bat file and edit it?
I have R2015b installed. I searched my computer for a mexopts.bat file, and found it in folders related to code I have from 2012-2013, but not in the new MATLAB install folder. For this reason I believe it's not a part of the standard MATLAB installation, which is probably why you didn't find it.
According to this thread it seems that the mexopts.bat file is no longer used in MATLAB starting R2014a, and instead you should look for these files:
mex_C_win32.xml
mex_C_win64.xml
MBUILD_C_win32.xml
MBUILD_C_win64.xml
If you are still convinced that you should find and edit a mexopts file, let me recommend you the Everything Search Engine to look for files on your hard-drive.

XMP toolbox for Matlab

Has anyone ever heard of something that might facilitate the work with XMP metadata in Matlab?
For instance, EXIF metadata can be read simply by using the exifread command -
output = exifread(filename);
I've found this thread, but it seems to be dead.
Currently I am thinking about the following options:
Writing MEX file using C++ XMP SDK
Calling Java routines using JAVA XMP SDK
To summarize, the question is:
Do you have any idea on how XMP can be read/written in Matlab?
XMP is just XML, so you can use any MATLAB XML toolbox. My personal favourite is xml_io_tools.
If you want to use the SDK to avoid having to manually interpret what bits of the XML means, then of your two options the Java one sounds preferable. Calling Java from MATLAB is straightforward, and you avoid the hassle of building things that MEX entails.
I have found the answer. The best way is to download ExifTool and any Matlab JSON parser. It is possible to extract it from any file format, including .DNG, .XMP, .JPEG, .TIFF.
Step 1: Extract the info into temporary JSON file by using
system(['exiftool -struct -j ' fileName '>' tempFile]);
Step 2: Call the JSON parser on the tempFile
Step 3: You have the data in Matlab struct.

Save currently running script in Matlab

Is there a way of saving the currently running script in Matlab? I have a script which automatically takes a backup of a set of scripts although if I have changed the current script then the saved version will be out of date.
Perhaps its possible to call some java?
Thanks
Somewhere on Yair Altman's site (see link in my other answer) he also referred to a blog entry about editorservices, which was introduced with MATLAB R2009b.
editorservices.getActive().save
should do what you want.
Okay, all I write here I learned from undocumentedmatlab.com by Yair Altman, in particular by looking into his EditorMacro.m... great stuff!
I'm assuming that Itamar Katz understood you correctly and that you are running unsaved code from the editor by using "Evaluate Cell" or "Evaluate Selection"; you want your code to realize that it is not saved and save the version currently displayed in the editor to some other location.
I have not found a way to save the file directly to the original location, but at least I have found a way to access the current text. You can then use fprintf to save it to wherever you want. I have tested this in Matlab 7.11 (R2010b); if you have a different version you'd need to dig through EditorMacro.m to find the correct code for Matlab 6.
if com.mathworks.mlservices.MLEditorServices.getEditorApplication.getActiveEditor.isDirty
thisdocument=com.mathworks.mlservices.MLEditorServices.getEditorApplication.getActiveEditor.getDocument;
thisdocument_text=char(thisdocument.getText(0,thisdocument.getLength));
fid = fopen('backupfile.m','w');
fprintf(fid, '%s', thisdocument_text);
fclose(fid);
else
% saved file is unmodified in editor - no need to play tricks...
...
end
So the if-condition checks if the currently active editor window contains a file which is not saved ("dirty"); if it is, we need to retrieve the current version of the code (into variable thisdocument_text) and save this string to some file.
Does this help?