09-28-2015 02:31 PM
Hello,
I have a working Matlab function (an .m file) for reading MiniSEED (data-only) datafile. It works great in Matlab and requires a filepath as an input parameter. If no file is input it opens a dialog to select one. However, when I import this m file into a MathScript node, LV insists that an input parameter is mandatory.
I cannot create a filepath input parameter (seems as MathScript node does not allow this?) - Is this possible and how? I would be very surprised if MathScript nodes only expect DBLs as inputs. Is there a workarround?
Thanks in advance,
G
09-28-2015 02:34 PM
I imagine that Mathscript files would treat filepaths as strings. So use some file dialog functions, and convert the filepath to a string before passing to the mathscript node.
09-28-2015 02:54 PM
Damn! Now I noticed - this is a function expecting variable number of input args and a status output arg. This is why LV shows broken run arrow and msgs following error:
A function is defined in this script. You must save and call the
function with appropriate input values to execute the function.
BTW, thank you RF, a string converted froma filepath is acceptable for the MathScript node.
Here is my situation, I can follow the m code, however cannot alter it though - not familiar! Since I would use it with only a single parameter (selected file) how should I "reformat" it not to be seen as a function, but rather as working code?
It is pretty readbale and well commented - anybody willing to parse it and remove the problem?
09-28-2015 04:11 PM
Why not simply code it in LabVIEW? If all it's doing is reading in a file and doing some simple parsing (as I gather from your comments), this should be duck soup. How complicated is the Matlab file? Can you post something?
Bob Schor
09-29-2015 02:43 AM
Hi Bob,
It is not simple at all. Attached is the file itself. I just realized the very 1st line which is the function declaration (so far I though of the listing as a kind of "main"). So filepath is not the input parameter but an array of cmd params (not exceeding 6 as I understand below). It reads block by block of data, each headered with a blockette that might differ. So my reluctance to code it in LV is based on the obvious fact that the structure X might differ from block to block. The X[i]s are read in a for loop and I can't figure out how Matlab knows the exact structure of read block.
Of course I will end up writing my own LV reader, but if I can make this work within a MathScript by using the "version" with just filepath as input parameter (other params implicit) I would save me a precious time 🙂
Comments are wellcome,
09-29-2015 09:45 AM
Wow, that is ugly.
Of course, there are other issues. Many of the FDSN codes would be easy to implement (ASCII, the integer and Float formats), but others are unknown to me (Steim, GEOSCOPE). The meaning and implication of some of the I-structure fields don't mean much to me, but clearly may have an implication on how the data in the blocks are combined. And then there's the nature of the plots.
Still, if this is the only place you would need to interact with Matlab, it becomes a judgment call whether it might be simpler, faster, more maintainable, dare we say "better?" to byte the bullet and write Read miniSEED File.vi. If it were my project, I'd invest at least a day or two in the attempt ...
Bob Schor