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