help-octave
[Top][All Lists]
Advanced

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

plot file using filename from data input file without extension


From: Tim at Gowing Engineering
Subject: plot file using filename from data input file without extension
Date: Tue, 11 May 2010 16:07:01 +0000 (GMT)

Hello,
I'm new to Octave although I have a basic working knowledge of Awk and C so sort of know what's going on.
 
I have a structure of several .m files containing a collection of functions.  The data which the program operates on is read in from a data file with a .dat extension. I am plotting the results of the calculations using the plot() command (invoking GnuPlot) and printing the plots to JPEG .jpg files using print -djpg data1-plota.jpg.
 
I would like to use the body of the filename from the data input file as part of the filename for the output plot files.
e.g. input file data_1.dat, outputplot files data1-plota.jpg, data1-plotb.jpg & data1-plotc.jpg
 
I have looked at the 'fileparts' function and means of string concatenation for the suffix but can't quite figure out the way to make it work.
 
I am employing the following code snippet to read in the data file:
 

global new fid

 

new = input('Create a new data file? (y/n)','s');

if strncmp(new,'y',1)

    filename = input('enter new filename: ','s');

    fid = fopen(filename,'w');

else

    fid = 0;

    while fid < 1

        filename = input('open filename: ','s');

        [fid, message] = fopen(filename,'r');

        if fid == -1

        display(message)

        display('press ^C to exit')

        end

    end

end

 

I'd be grateful for any pointers towards accomplishing this.

 

Regards, Tim


reply via email to

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