help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Generate plots in bash script


From: Ben Abbott
Subject: Re: Generate plots in bash script
Date: Thu, 29 Nov 2012 19:27:14 -0500

On Nov 29, 2012, at 6:52 PM, epetting wrote:

> Hello!
> 
> I'm attempting to be more concise and simply run an Octave file which
> generates plots within a bash script (also, the Octave file does not require
> bash parameters to be used). 
> 
> The octave file runs fine in octave, and looks like the following (called
> Plot1.m):
> ~~~~~~~~~~~
> clear all; 
> close all;
> a=dlmread('file1');aT=a(:,1);aV=a(:,2);
> 
> figure 
> plot(aT,aV);
> 
> print -dpdf Attempt.pdf
> ~~~~~~~~~~~
> 
> 
> The bash scripts I've made (none work):
> ~~~~~~
> #!/bin/bash
> cd /Users/me
> octave -q << eof
> Plot1
> eof
> ~~~~~~
> 
> and 
> 
> ~~~~~
> #!/bin/bash
> cd /Users/me
> octave --silent --eval 'Plot1'
> ~~~~~
> 
> and 
> 
> ~~~~~
> #!/bin/bash
> cd /Users/me
> octave -qf Users/me/Plot1.m
> ~~~~~

If you just want to run an Octave m-file script from the shell, then add the 
line below to the top of your file (depending upon where your octave is 
installed, this line may need to change).

        #! /opt/local/bin/octave -qf

Thus, your Plot1.m file's contents would be ....

~~~~~~~~~~~
#! /usr/bin/octave -qf
clear all; 
close all;
a=dlmread('file1');aT=a(:,1);aV=a(:,2);
figure 
plot(aT,aV);
print -dpdf Attempt.pdf
~~~~~~~~~~~

Then change the permissions ....

        chmod 755 Plot1.m

... and run the script.

Ben



reply via email to

[Prev in Thread] Current Thread [Next in Thread]