View HDF5 inside matlab - matlab

Just how good is MATLAB in opening and viewing HDF5 files? I can see there are a couple of h5... commands but I'm wondering if there is a way to "view" the file interactively as you could do with a .mat file or like HDFView tool?

We use Matlab and we use HDF5 files. We also use a lot of Fortran, and one of the reasons we use HDF5 is to store datasets which can be read and written both by Fortran and Matlab. Matlab vs Fortran for HDF5 is a bit like Matlab vs Fortran for most things, the former is easier to use, lets you try out ideas quickly, and gives you much tighter integration between data and visualisation. You may have your own views on Matlab vs your favourite compiled language.
Matlab provides a complete (maybe not entirely complete, but we haven't found any features of the HDF5 Fortran APIs that we want to use that Matlab doesn't provide) interface to HDF5. When you view the document that #GuntherStruyf pointed you at, read to the bottom where you can find information about Matlab's low-level HDF5 access functions. You can do a lot with the high-level access functions alone, but not everything. And if you are already used to the HDF5 API for Fortran/C/C++, taking the same approach in Matlab and ignoring the higher-level functions is easy enough.
But we do use HDFView too, it's an easy way to trawl through an HDF5 file and, within certain limitations, an easy way to quickly edit an HDF5 file. You can, for instance, cut and paste from Excel to HDFView; perhaps more relevant you can cut and paste from Matlab's variable editor. Matlab doesn't quite provide that level of easiness for viewing HDF5 files.
To sum up:
HDFView for viewing and interactive editing
Matlab for programming for prototyping and rapid deployment
Fortran/C/C++ for programming for heavy-lifting.

Related

Browse MATLAB integrated functions

I tried to find the source code for some integrated MATLAB functions. Is there any way to find MATLAB's integrated functions? For example I can't find hypot source code.
Most MATLAB functions are supplied as MATLAB source code, and you can view the source by typing edit <functionname>. Some of the lower level functions, however, are implemented in C for better performance and are built-in - you can't see the source code. hypot is one of these.
However the algorithms are not typically that secret - you can read an article about hypot (including the algorithm) on Cleve Moler's blog.

Using a MATLAB code on Scilab

Is it possible to use a MATLAB code on Scilab? Is that what is meant when saying that Scilab is a "clone" from MATLAB?
There is a tool to automatically convert Matlab source to Scilab source, it's called M2SCI. A script parses the Matlab source code and replaces Matlab-specific functions by Scilab ones. See the documentation of the mfile2sci function.
Yes you can use MATLAB code on scilab. See these links for more information:
http://help.scilab.org/docs/5.4.0/fr_FR/section_36184e52ee88ad558380be4e92d3de21.html
http://help.scilab.org/docs/5.4.0/en_US/index.html
I would not bet on it. But if your code is simple enough chances are good.
Problems are:
There is encrypted p-code in Matlab that Scilab will not be able to open.
Matlab usually comes with a number of toolboxes that might not be available to you (i think especially Simulink)
last but not least (i don't know about scilab) there usually are minute differences in how functions are implemented.
There are a number of projects out there trying to replicate/replace MATLAB:
Julia language: which has a relatively similar syntax to MATLAB and offers great performance, but still lacks a lot of toolboxes/libraries, as well as not having a GUI like MATLAB. I think this has the brightest future among all MATLAB alternatives.
Python language and its libraries NumPy and matplotlib: which is the most used alternative. I think at this moment the community is a couple of orders of magnitude even bigger than MATLAB. Python is the de facto standard in machine learning and data science at the moment. But still, the syntax and memory concept is a bit far from what people are used to in the MATLAB ecosystem. There are also no equivalent to SIMULINK, although Spyder and Jupyter projects have come a long way in terms of the development environment.
Octave: is basically a clone of MATLAB to a point they consider any incompatibility as a bug. If you have a long MATLAB code that you don't want to touch, this is the safest bet. But again no alternative for SIMULINK.
SciLab and it's fork ScicoLab are the best alternatives in terms of GUI, having a SIMULINK replica xcos / scicos and a graphical user interface development features. However the community is not as big as Octave and the syntax is not completely compatible. Sadly the Scilab development team has gone through a devastating family crisis leading to the software falling behind.
Honorary mention of Modelica language implementations OpenModelica and jModelica for being a superior alternative to SIMULINK-SimScape. You should know that you can load Modelica scrips also in xcos and scicos. If you want to kno wmore about JModelica you may see this post.
you may check the MATLAB's Alternativeto page to see more Free and Open source alternatives.

Distribute matlab functions without source

I have written a set of Matlab functions and I want to distribute it to few people for testing. But I do not want to reveal the source to them. All these people have matalb installed on their systems. So I don't want to make standalone executable from my functions. Ideally I want something like complied library files which the users can put in the matlab path & call the functions from their matlab prompt / matlab functions. Is it even possible ?
Edit: I have matlab compiler toolbox. But the users won't be having access to matlab compiler toolbox on their matlab.
The standard way is using pcode. Look in the docs and remember to keep a copy of the source code elsewhere!

3D-accellerated plotting, as flexible as matlab, mathematica etc?

I am looking for a library to plot large data sets with a feature set similar to professional plotting tools (e.g. Matlab, Mathematica), but 3D accelareted. In particular I value
can be scripted like the professional tools above (flexible usage)
has a feature at least as big as these
fast (well, that's what the title says)
I can imagine (actually, I have very much in mind) something like this might exist for python - say, NumPy, SciPy. But I am not well-versed with these libraries yet. It would be great if I could convince people to abandon matlab.
Check out Mayavi, a 3d visualization package for Python that wraps around VTK. It's very flexible, has decent documentation, and hardware-accelerated rendering.
MathGL is cross-platform GPL library written in C/C++ which can plot huge data set (including 2- and 3-ranged data). Its list of graphics types is the same or larger than ones in Matlab and in Mathematica. MathGL have its own scripting language (MGL) and have interfaces to Python (including numpy), Fortran, Octave, Forth, Pascal and so on.

MATLAB programming best practices

I'm looking for resources on how to structure medium- to large-scale MATLAB projects, especially ones that involve several independent modules. How do I manage global configuration variables, how do I structure the project into folders, how do I manage couplings between modules, etc.
Is there some kind of standard text on this subject? It looks as if most MATLAB textbooks have been written by scientists or engineers. What I'm looking for, I guess, is any MATLAB textbook written by a software engineer. :-)
MATLAB is an unusual choice for a large-scale projects and is as much suited for such task as assembler, COBOL or SQL. If you still choose MATLAB then at least automatically test the code! All kind of tests - integration tests, unit tests, load tests! And of course use a version control system.
As said, MATLAB was not created with large projects in mind therefore the only best practice regarding project structure, modules, coupling is the common sense.
If you are taking over an existing large MATLAB project then I am sorry with you, refactoring will be nightmare. If you are going to start a new large project with MATLAB then you are crazy - there are much better alternatives to MATLAB that are not that bad regarding numeric performance. Large project implies that almost all code is business logic, not numerics, therefore why for God's sake MATLAB?
Large project implies well structured components, which implies OO, which is the weak point of MATLAB because it sacrifices heap performance for numeric performance to the degree of unusability.
My experience:
I spent years in in a half-million LOC MATLAB project.
I have seen painless transition of multiple large MATLAB projects to C#.
With MATLAB you still have to use large amounts of Java for decent looking GUI, C/C++ MEX for fast not numeric parts like imports, maybe SQL, etc. With Java (or better C#) with a free numeric library you have only one language which is perfectly suited for everything you need in a large project.
I am not saying that MATLAB is bad - it rules for rapid prototyping and numerics! And Simulink has no alternatives (but can be compiled and used from everywhere).
You may want to have a look at "The Elements of Matlab Style" (review by Loren Shure).
Also, this review of good coding practices might be useful.