LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-15-2012, 02:55 PM   #1
atjurhs
Member
 
Registered: Aug 2012
Posts: 305

Rep: Reputation: Disabled
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:
fnarr = '/home/tabitha/many_files/file_typeA_1.txt';
%fnarr = '/home/tabitha/many_files/file_typeA_2.txt';
%fnarr = '/home/tabitha/many_files/file_typeA_3.txt';
%fnarr = '/home/tabitha/many_files/file_typeB_1.txt';
%fnarr = '/home/tabitha/many_files/file_typeB_2.txt';
%fnarr = '/home/tabitha/many_files/file_typeB_3.txt';
%fnarr = '/home/tabitha/many_files/file_typeC_1.txt';
%fnarr = '/home/tabitha/many_files/file_typeC_2.txt';
%fnarr = '/home/tabitha/many_files/file_typeC_3.txt';

etc....

MatLab_Processing_Tool( fnarr );
call me lazy but, I just don't want to have to pass into fnarr paths and file names 100 or more times

thanks so much, Tabitha
 
Old 10-15-2012, 04:53 PM   #2
alinas
Member
 
Registered: Apr 2002
Location: UK, Sywell, EGBK
Distribution: RHEL, SuSE, CentOS, Debian, Ubuntu
Posts: 60

Rep: Reputation: 20
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.
 
Old 10-15-2012, 10:22 PM   #3
atjurhs
Member
 
Registered: Aug 2012
Posts: 305

Original Poster
Rep: Reputation: Disabled
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
 
Old 10-15-2012, 10:44 PM   #4
Kenarkies
Member
 
Registered: Nov 2007
Location: South Australia
Distribution: Ubuntu 11.10
Posts: 81

Rep: Reputation: 23
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.
 
Old 10-15-2012, 11:02 PM   #5
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
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.
 
Old 10-16-2012, 05:27 AM   #6
padeen
Member
 
Registered: Sep 2009
Location: Perth, W.A.
Distribution: Slackware, Debian, Gentoo, FreeBSD, OpenBSD
Posts: 208

Rep: Reputation: 41
If I understand you, you want to pass the ListFile line-by-line to M_P_T? Create this file runMPT

Code:
#!/bin/sh

cat ListFile | { while read LINE ; do
     Matlab_Processing_Tool($LINE)
     done
}
Make it executable chmod +x runMPT and you should be good to go.

@meninvenus: how do you write inline code with mono font, as per your chmod example?
 
Old 10-16-2012, 02:52 PM   #7
atjurhs
Member
 
Registered: Aug 2012
Posts: 305

Original Poster
Rep: Reputation: Disabled
I got this one solved by a little while loop
 
Old 10-17-2012, 12:06 AM   #8
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by padeen View Post
@meninvenus: how do you write inline code with mono font, as per your chmod example?
In advanced reply mode (not in quick reply), select the text you want to change font type, and then under fonts option, select courier or Fixedsys font. It will work. :-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Event Processing with List as Input sleepylamp Linux - Newbie 0 06-02-2009 10:00 AM
mac osx scripting/batching for gimp babag Programming 1 01-14-2007 05:16 AM
Linux batching mebrelith Linux - Newbie 1 02-08-2005 06:32 PM
Python CGI - Batching in R larsenmtl Programming 1 09-29-2004 04:24 PM
How To Input Characters In A List bprasanth_20 Programming 10 10-30-2003 12:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration