I have no bash scripting background. I know the basics of unix command line.
I have a matlab script that takes in an matrix image as input. I have a bunch of images in a file. I need the bash script to call the matlab program and feed every single image in the file as input to the program one by one.
If you want to write it go ahead that would be great. All I'm asking is for someone to direct me to exactly what I should look into.
Thanks
Assume that the matlab command is in your path (for more info, See the documentation )
Supposing you just wanted to get all of the BMP's (you didn't specify file type), you can use a simple bash loop:
for f in *.BMP; do
matlab -nosplash -nodisplay -nojvm -r "my_command('$f'),quit()"
done
The -nosplash, -nodisplay, and -nojvm ensure that the GUI isn't triggered, and the -r instructs matlab to run the command. The ,quit() at the end ensures that matlab quits after running.
You need
list_images, or a filename what contains the list of imagesSomething like:
list_images | while read image_name
do
matlab_command "$image_name" > "$image_name.output"
done
or better
while read image_name
do
matlab_command "$image_name" > "$image_name.output"
done < filename_with_images.txt
Not really understand what you mean with the have amatrix images in a file, post an example of your input.
EDIT for finding prj files in the curent directory
find . -maxdepth 0 -name \*.prj -print0 | while IFS= read -r -d '' image_name
do
matlab_command "$image_name" > "$image_name.output"
done
Google for "bash tutorial".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With