From: MichaelBrandhorn on 8 Aug 2010 16:04 I have approx. 5000 files of data in m-file script format, each one containing a mess of matlab vectors/matrices. This files are grouped in groups of 20. For each pack of 20, I want to read out the values of a number of this vectors and write them into a textfile (with a given format and sequence). Now, as a first step I wanted to load the aformentioned vectors into the workspace. For obvious reasons I'm not inclined to do this per hand (i.e. run 'file' in command window) but wanted to do a function, which I can give the path and an identifier for which pack I want, that then reads the m-files in automatically. This works fine until I try to run the data-m-files from my script, as the vectors simply do not show up in the workspace. Is there a better solution to this? Or any way to run a script from a function, that will make the variables of script show up in the workspace? Thanks for your time and effort
From: ImageAnalyst on 8 Aug 2010 20:28 I think you'd have to alter your 5000 files to return the variables that you need to have in your calling routine's workspace. Otherwise any variables that these m-files create get destroyed when that m-file exits. I don't know any other way around it. You could write some script to try to automate the returning of the variables. It might not be too bad as long as all your m-files were fairly similar in their structure. If they're way different then you've got a problem. As one way to do it, maybe you can just add a line to the end of the m-files to save all their currently-existing variables to a file, then use load() to read them back into a structure in your calling routine's workspace. That might work as long as all your scripts exit at the same place (e.g. at the last line).
From: MichaelBrandhorn on 9 Aug 2010 00:05 You, good sir, are a god among men. I might have to type 20 versions or so but that's still music to my ears, compared to the possibility of truding through all this data per hand.
From: Malcolm McLean on 9 Aug 2010 05:11 Basically your files are not .m files. They are raw data files which just happen to be in the .m format. Use textscan and other functions to read them in as data.
|
Pages: 1 Prev: non linear simultaneous eqns Next: excel actixserver graph plot problem |