batching over an input list
Hi guys,
hope you guys can help.... I have a MatLab code that I'll call "MatLab_Processing_Tool" that takes the path and filename from a file that list them out. I'll call that text file "ListFile". Right now in ListFile I have to comment out and in the filenames and paths (one at a time) to get the MatLab_Processing_Tool to run, but the problem I have is like 100 or more of these text files need to be run by passing them into it the path and filename and assigned by fnarr. I know how to create the ListFile, but can I somehow batch assigning them to fnarr? "ListFile" Code:
thanks so much, Tabitha |
I can't answer your question, because I don't know Matlab language. But that's my point. I think you are more likely to get an answer from a more specific forum, such as http://www.mathworks.co.uk/matlabcentral.
|
I don't think, but I could be wrong, that this is not a MatLab question at all. The only thing that MatLab cares about is what path and file is assigned to fnarr. So I jsut need a script that feeds MatLab a new fnarr every time it makes a call for one. Also I'm pretty sure that MatLab will take standard shell commands, maybe even awk
|
Yes we may be able to help but we need more clarification. Am I right in understanding that you have a file with a list of filenames, and you want to feed them one at a time to another program (MatLab_Processing_Tool in this case). By the look of it you are commenting out all but one file (using % as a comment directive) and feeding the resultant file to Matlab. The last line - is that a part of the file or is it a script run inside Matlab. Are you wanting to run this "MatLab_Processing_Tool" on each filename at a time? If so, wouldn't that need a Matlab script? I confess to being a bit lost.
Is there a way to invoke MatLab_Processing_Tool outside of Matlab just using the desired filename? (e.g. matlab -f filename.txt or something) so that you can build a script to extract one filename from the listfile at a time and feed it to Matlab. That shouldn't be too hard to do in bash. Otherwise there are tools to either comment out or delete unwanted names. |
As far as I unuderstood, you want to pass all files one by one to MatLab_Processing_Tool( fnarr ).... Right?
Well, this could be achieved by using a simple shell script. First, get a list of all files that you want to pass into the fnarr, as follow: ls -la | awk -F" " '{print $8}' > /tmp/ListFiles.txt Then create a simple script as: #!/bin/sh LIST="/tmp/ListFiles.txt" for file in `cat $LIST` do MatLab_Processing_Tool( fnarr ) done Make this script executable using chmod +x scriptname.sh and invoke using ./scriptname.sh So try it out, and let's know if you still have any issue. |
If I understand you, you want to pass the ListFile line-by-line to M_P_T? Create this file runMPT
Code:
#!/bin/sh @meninvenus: how do you write inline code with mono font, as per your chmod example? |
I got this one solved by a little while loop
|
Quote:
|
All times are GMT -5. The time now is 05:11 AM. |