help-octave
[Top][All Lists]
Advanced

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

using eval with multiple variable strings


From: Sarah Caudill
Subject: using eval with multiple variable strings
Date: Sat, 30 Jan 2010 19:42:13 -0600

Hello,

I am new to using octave and would like to port some of my matlab
code. I am using octave version 3.0.1.

I will post my matlab code below. Basically, I am using a function
called scatter_plots to make a scatterplot. The function inputs
include a couple of strings that will be used in the naming
conventions for plot axes, titles, legend, and plot names. I have
utilized 'eval' multiple times to do this. I also read in two .mat
files with the signal-to-noise ratio (snr) data that is to be plotted.

The main problem is that the eval statement seems to behave very
differently in octave. For example, if I set veto_level='CAT2',
injtype='EOBNR', ifo2='H', and ifo1='L', my plot title using my matlab
code will be: CAT2 EOBNR: H SNR versus L SNR

Also I am having alot of difficulty figuring out how to save the plot.
I want to save it as a png and give it a name based on inputs.
However, it is not obvious to me how to use the octave print command
with eval so that I can use multiple strings in the the file name.

Thus, I cannot figure out how to use octave's eval statement to take
in my various string inputs. Maybe I shouldn't be using eval at all.
Can anyone help me rewrite the code for plotting that I've pasted
below.

%%%%%%%%%%%%%%%%%MATLAB CODE%%%%%%%%%%%%%%%%%%%%%
function scatter_plots( veto_level, coinctype, ifotime, ifo1, ifo2,
data1, data2, injtype)

  % read in the data files
  eval(['datax=load(''' data1 ''');'])
  eval(['datay=load(''' data2 ''');'])

  figure
  loglog(datax.snr, datay.snr, 'kx');
  grid on
  eval(['x_lab=xlabel(''\rho_{' ifo1 '}'');'])
  eval(['y_lab=ylabel(''\rho_{' ifo2 '}'');'])
  set(x_lab,'FontSize',14);
  set(y_lab,'FontSize',14);
  set(gca,'FontSize',14);
  eval(['plot_title=title(''' veto_level ' ' injtype ': ' ifo2 ' SNR
versus ' ifo1 ' SNR'');'])
  set(plot_title,'FontSize',14,'FontWeight','b');
  eval(['leg=legend(''Background ' coinctype ' coincidence in '
ifotime ' time'',''Injections ' coinctype ' coincidence in ' ifotime '
time'',0);'])
  set(leg,'FontSize',14);
  eval(['saveas(gcf,''' veto_level '_' injtype '_' ifo1 '' ifo2
'_H1H2L1_H1H2L1_snrscatterplot.png'')'])


reply via email to

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