예제 #1
0
void gnuplot_histogram(long int y[], double maxy, int n, char *outfileroot,
		       char *filename, int displayplot){

  char gnuplotcommands[1024];
  char file[2056],logfile[2056];
  FILE *datafile,*gnuplotlogfile;
  long int i,val;

  sprintf(logfile,"%s_%s%s",outfileroot,filename,"_gnuplot.script");
  gnuplotlogfile = fopen(logfile,"w+"); /* Setup a log file for
					   gnuplot commands used */

  sprintf(file,"%s_%s.dat",outfileroot,filename);
  datafile = fopen(file,"w+"); /* overwrites old files */

  for (i=0; i<n; i++)
    {
      val=*( y + i );
      fprintf(datafile,"%li \n",val);
    }
  fclose(datafile);
    
  /* Make plot  */
  sprintf(gnuplotcommands,"plot \\\"");
  sprintf(gnuplotcommands,"%s%s",gnuplotcommands,file);
  sprintf(gnuplotcommands,"%s\\\" with lines ",gnuplotcommands);

  gnuplot(gnuplotcommands,gnuplotlogfile,displayplot);

  fclose(gnuplotlogfile);
}
예제 #2
0
void gnuplot_plot(double y[], int n, double scaling, char *outfileroot, char *filename,int displayplot){

  char gnuplotcommands[1024];
  char file[2056],logfile[2056];
  FILE *datafile,*gnuplotlogfile;
  int i;

  sprintf(logfile,"%s_%s%s",outfileroot,filename,"_gnuplot.script");
  gnuplotlogfile = fopen(logfile,"w+"); /* Setup a log file for
					   gnuplot commands used */

  sprintf(file,"%s_%s.dat",outfileroot,filename);
  datafile = fopen(file,"w+"); /* overwrites old files */

  for (i=0; i<n; i++) {
    fprintf(datafile,"%i %f\n",i,y[i]*scaling);
  }
  fclose(datafile);
    
  /* Make plot of chopping function */
  //  sprintf(gnuplotcommands,"set xlabel \\\"Time (seconds)\\\"\n");
  //  sprintf(gnuplotcommands,"%s plot\\\"",gnuplotcommands);
  sprintf(gnuplotcommands,"plot\\\"");
  sprintf(gnuplotcommands,"%s%s",gnuplotcommands,file);
  sprintf(gnuplotcommands,"%s\\\"",gnuplotcommands);
  gnuplot(gnuplotcommands,gnuplotlogfile,displayplot);

  fclose(gnuplotlogfile);

}
예제 #3
0
void gnuplot_plot2d(double y[], double x[], int n, char *outfileroot,
		    char *filename, int displayplot){

  char gnuplotcommands[1024];
  char file[2056],logfile[2056];
  FILE *datafile,*gnuplotlogfile;
  int i;

  sprintf(logfile,"%s_%s%s",outfileroot,filename,"_gnuplot.script");
  gnuplotlogfile = fopen(logfile,"w+"); /* Setup a log file for
					   gnuplot commands used */

  sprintf(file,"%s_%s.dat",outfileroot,filename);
  datafile = fopen(file,"w+"); /* overwrites old files */

  for (i=0; i<n; i++) {
    fprintf(datafile,"%f  %f\n",x[i],y[i]);
  }
  fclose(datafile);
    
  /* Make plot  */
  sprintf(gnuplotcommands,"plot\\\"");
  sprintf(gnuplotcommands,"%s%s",gnuplotcommands,file);
  sprintf(gnuplotcommands,"%s\\\"",gnuplotcommands);

  //  gnuplot(gnuplotcommands,gnuplotlogfile);
  gnuplot(gnuplotcommands,gnuplotlogfile,displayplot);

  fclose(gnuplotlogfile);
}
예제 #4
0
/* Plot all the data accumulated in a file with gnuplot */
void plot_data(char *filename) {
  char gnuplot_command[250];

  /* Plot the data */
  sprintf(gnuplot_command, "plot \'%s\'\n", filename);
  gnuplot(gnuplot_command);
}
예제 #5
0
int main(int argc, char **argv) {



    printf("\n======= GCOR v1.1 - Automatic Gain Correction =======\n\tR. Lica, IFIN-HH, Dec2013 \n\n");



    int chNum, detNum, runstart, runstop, irun, idet;
    int minWIDTH, maxWIDTH, SHIFT, SWEEP, degree;
    int low, high;
    char name[20];

    FILE *settings, *fi, *fo;
    initialize(settings, &chNum, &detNum, name, &runstart, &runstop, &minWIDTH, &maxWIDTH, &SHIFT, &SWEEP, &degree, &low, &high);

    degree++; // in the program degree represents the number of coefficients of the polynomial and NOT the degree of the polynomial. i know...
    int regions=(high-low)/SHIFT;
    struct Data2Fit shData[regions];
    int i, j, k, nData=0;
    double refSpec[chNum], Spec[chNum];
    double coeff[degree], chisq, norm;
    FILE * gnuplotPipe = popen ("gnuplot", "w");
    char outfile[20], infile[20], answer;
    sprintf(outfile, "gcor.cal");
    fo=fopen(outfile, "wt");




    for(idet=0; idet<detNum; idet++)
    {

        fprintf(fo, "%5d%5d%5d%9.3f%10.6f\n", runstart, idet, 2, 0.0, 1.0); //each detector from the first run is set as reference

        for(irun=runstart+1; irun<=runstop; irun++)
        {

            for (i=0; i<regions; i++)
            {
                shData[i].ch=0;
                shData[i].chShift=0;
                shData[i].err=0;
            }

            sprintf(infile, "%2s.%04d", name, runstart);
            if(fopen(infile, "rb")) fi=fopen(infile, "rb");
            else {
                printf("Cannot open %2s.%04d\n", name, runstart);
                exit(0);
            }
            readBin(fi, refSpec, idet, chNum, low, high);

            sprintf(infile, "%2s.%04d", name, irun);
            if(fopen(infile, "rb")) fi=fopen(infile, "rb");
            else continue;
            readBin(fi, Spec, idet, chNum, low, high);


            normalize(refSpec, Spec, chNum, &norm);
            smooth(refSpec, Spec, minWIDTH/5, maxWIDTH/2, low, high);
            deriv(refSpec, Spec, low, high, 5);


            autoshift(refSpec, Spec, shData, low, high, minWIDTH, maxWIDTH, SHIFT, SWEEP, regions);


            nData = performFit(shData, degree, &chisq, coeff, regions);
            if (nData == 0) {
                printf("Warning! %2s#%02d.%04d: Could not extract data suitable for fit. Change settings!\n", name, idet, irun);
                goto skip;
            }
            gnuplot(gnuplotPipe, irun, idet, shData, nData, degree, chisq, coeff, regions, norm);
            writeCal(fo, degree, coeff, irun, idet);

            if (answer=='a') goto skip;
            printf("Going to %2s#%02d.%04d ([y]/n)? (Type 'a' for automatic fit)", name, idet, irun+1);
            answer = getchar();
skip:
            if (answer=='n') exit(0);


        }

        printf("---------------------\nGoing to Detector #%02d\n---------------------\n", idet+1);




    }

    exit(0);


}
예제 #6
0
//----- the rprop wrapped with stopping criteria
uint Rprop::loop(arr& _x,
                 ScalarFunction& f,
                 double *fmin_return,
                 double stoppingTolerance,
                 double initialStepSize,
                 uint maxEvals,
                 uint verbose) {

    if(!s->stepSize.N) init(initialStepSize);
    arr x, J(_x.N), x_min, J_min;
    double fx, fx_min=0;
    uint rejects=0, small_steps=0;
    x=_x;

    if(verbose>1) cout <<"*** optRprop: starting point x=" <<x <<endl;
    ofstream fil;
    if(verbose>0) fil.open("z.opt");

    uint evals=0;
    double diff=0.;
    for(;;) {
        //checkGradient(p, x, stoppingTolerance);
        //compute value and gradient at x
        fx = f.fs(J, NoArr, x);
        evals++;

        if(verbose>0) fil <<evals <<' ' <<eval_cost <<' ' << fx <<' ' <<diff <<' ' <<x <<endl;
        if(verbose>1) cout <<"optRprop " <<evals <<' ' <<eval_cost <<" \tf(x)=" <<fx <<" \tdiff=" <<diff <<" \tx=" <<x <<endl;

        //infeasible point! undo the previous step
        if(fx!=fx) { //is NAN
            if(!evals) HALT("can't start Rprop with unfeasible point");
            s->stepSize*=(double).1;
            s->lastGrad=(double)0.;
            x=x_min;
            fx=fx_min;
            J=J_min;
            rejects=0;
        }

        //update best-so-far
        if(evals<=1) {
            fx_min= fx;
            x_min=x;
        }
        if(fx<=fx_min) {
            x_min=x;
            fx_min=fx;
            J_min=J;
            rejects=0;
        } else {
            rejects++;
            if(rejects>10) {
                s->stepSize*=(double).1;
                s->lastGrad=(double)0.;
                x=x_min;
                fx=fx_min;
                J=J_min;
                rejects=0;
            }
        }

        //update x
        s->step(x, J, NULL);

        //check stopping criterion based on step-length in x
        diff=maxDiff(x, x_min);

        if(diff<stoppingTolerance) {
            small_steps++;
        }
        else {
            small_steps=0;
        }
        if(small_steps>3)  break;
        if(evals>maxEvals) break;
    }
    if(verbose>0) fil.close();
    if(verbose>1) gnuplot("plot 'z.opt' us 1:3 w l", NULL, true);
    if(fmin_return) *fmin_return= fx_min;
    _x=x_min;
    return evals;
}
예제 #7
0
파일: plot.cpp 프로젝트: cationly/MFHUB
int plot( const GlobalSettings& settings, const SCCResults& results,
          const string& root_dir, int id )
{

  // ----- RESULT OUTPUT TO FILE AND PLOTTING -----

  int const& s = settings.s;

  // make an output directory

  string dir;
  if ( id != -1 ) {
    stringstream tmp;
    tmp << setfill( '0' );
    tmp << "./" << root_dir << "/" << id << '/';
    dir = tmp.str();
    if ( system( ( "test -e " + dir + " || mkdir " + dir ).c_str() ) != 0 ) {
      #pragma omp critical (output)
      { cerr << id << ": ERROR -> unable to create the output directory!"; }
      return 1;
    }
  } else {
    dir = "./" + root_dir + "/";
  }

  ofstream n_log( ( dir + "n.log" ).c_str() );
  if ( !n_log.is_open() ) {
    #pragma omp critical (output)
    { cerr << "ERROR: unable to open occupation output file?" << endl; }
    return 1;
  }
  n_log << setiosflags( ios::scientific );
  n_log.setf( ios::showpos );
  n_log.precision( numeric_limits<fptype>::digits10 + 1 );

#ifdef _VERBOSE
  cout << "Final mean field parameters:" << endl;
#endif
  for ( int i = 0; i < s * s; ++i ) {
#ifdef _VERBOSE
    cout << i << ' ' << idx2x( i, s ) << ' ' << idx2y( i, s ) << ' ' << results.n_up( i ) << ' ' << results.n_down( i ) << endl;
#endif
    n_log << i << ' ' << idx2x( i, s ) << ' ' << idx2y( i, s ) << ' ' << results.n_up( i ) << ' ' << results.n_down( i ) << endl;
  }

  n_log.close();

#ifdef _VERBOSE
  cout << endl << "Plotting ...";
  cout.flush();
#endif

  ofstream gnuplot( ( dir + "plot.gnu" ).c_str() );
  if ( !gnuplot.is_open() ) {
    #pragma omp critical (output)
    { cerr << id << ": ERROR -> unable to create gnuplot script?" << endl; }
    return 1;
  }
  gnuplot << "\
	set terminal pngcairo size 1000,600 \n\
	set size ratio 2/3 \n\
	set xrange [0:" << 1.5 * ( s - 1 ) << "] \n\
	set yrange [0:" << s - 1 << "] \n\
	set tics out \n\
	set cbtics in \n\
	set cbtics \n\
	set dgrid3d " << s * 10 << "," << s * 10 << ",3 \n\
	set pm3d map \n\
	set arrow from 0,0 to " << 0.5 * ( s - 1 ) << "," << s - 1 << " nohead front \n\
	set arrow from " << s - 1 << ",0 to " << 1.5 * ( s - 1 ) << "," << s - 1 << " nohead front \n\
	set output 'm_plot.png' \n\
	set cblabel \"m_z\" \n\
	splot 'n.log' using ($2+0.5*$3):3:($4-$5) notitle \n\
	set output 'n_up_plot.png' \n\
	set cblabel \"n_up\" \n\
	splot 'n.log' using ($2+0.5*$3):3:4 notitle \n\
	set output 'n_down_plot.png' \n\
	set cblabel \"n_down\" \n\
	splot 'n.log' using ($2+0.5*$3):3:5 notitle";
  gnuplot.close();

  if ( system( ( "cd " + dir + " ; gnuplot plot.gnu" ).c_str() ) != 0 ) {
    cerr << id << ": WARNING -> gnuplot call returned exit code != 0" << endl;
  }

#ifdef _VERBOSE
  cout << " done!" << endl;
#endif

  return 0;
}
예제 #8
0
void MainWindow::saveResultsAndInvokeGnuplotIfRequested(QVector<double> objectiveFunctionValues, QVector<int> solution)
{
	QVector<double> averageBusStopIds = QVector<double>::fromStdVector(algorithm->getAverageBusStopIds());
    QVector<int> rejectedSolutions = QVector<int>::fromStdVector(algorithm->getAmountOfRejectedSolutions());
    /*
    qDebug() << "Objective function values";
    for ( int i = 0; i < objectiveFunctionValues.size(); i++ )
	{
		qDebug() << objectiveFunctionValues.at(i);
    }
    */

	QString dataPrefix = "values_";
	QString params = QString("alpha_") + QString::number(Parameters::getAlpha())
			+ QString("_lambda_") + QString::number(0)                                  // TODO : here insert lambda value
			+ QString("_replacements_") + QString::number(Parameters::getNumberOfReplacementBusStops())
			+ QString("_solutions_") + QString::number(10)                              // TODO : here insert number of solutions in population
			+ QString("_iterations_") + QString::number(algorithm->getNumberOfIterations());
	QString dataExtension = ".txt";
	QString dataFilename = dataPrefix + params + dataExtension;
	QFile valuesFile(dataFilename);
    QFile busLineFile("bus_line_"+ params + dataExtension);
    if ( (!valuesFile.open(QFile::WriteOnly)) || (!busLineFile.open(QFile::WriteOnly)) )
	{
		QMessageBox::information(NULL, "Błąd pliku", "Otwieranie pliku do zapisu danych nie powiodło się", QMessageBox::Ok);
		return;
	}
	QTextStream values(&valuesFile);
    QTextStream busLine(&busLineFile);
    values << "iteration" << "\t\t" << "objectiveFunctionValues" << "\t\t" << "averageBusStopIds"
           << "\t\t" << "recjectedSolutions" << endl;
	for ( int i = 0; i < objectiveFunctionValues.size(); i++ )
	{
        values << i + 1 << "\t\t" << objectiveFunctionValues.at(i) << "\t\t" << averageBusStopIds.at(i)
               << "\t\t" << rejectedSolutions.at(i)<< endl;
	}
    for ( int i = 0; i < solution.size(); i++)
    {
        busLine << solution.at(i) << "\t" << endl;
    }

	if ( ui->generateGnuplotCheckbox->isChecked() )
	{
		qDebug() << "Generating gnuplot";
		QString gnuplotPrefix = "gnuplot_";
		QString gnuplotExtension = ".gpl";
		QString gnuplotFilename = gnuplotPrefix + params + gnuplotExtension;

		QFile gnuplotFile(gnuplotFilename);
		if ( ! gnuplotFile.open(QFile::WriteOnly) )
		{
			QMessageBox::information(NULL, "Błąd pliku", "Otwieranie pliku nie powiodło się", QMessageBox::Ok);
			return;
		}
		QTextStream gnuplot(&gnuplotFile);
		gnuplot << "set terminal eps enhanced" << endl << endl
				<< "set output '" << "plot_" << params << ".eps'" << endl << endl
				<< "set xlabel 'Numer iteracji'" << endl
				<< "set ylabel 'Wartosc funkcji celu'" << endl
				<< "set y2label 'Sredni Id przystanku'"<< endl
				<< "set ytics" << endl
				<< "set y2tics" << endl
				<< "set title 'Wartosc maksymalna funkcji celu rozwiazania w kolejnych iteracjach'" << endl << endl
				<< "plot '" << dataFilename << "' using 1:2 title 'Funkcja celu' smooth unique axes x1y1, \\" << endl
				<< "'" << dataFilename << "' using 1:3 title 'Sredni Id przystanku' smooth unique axes x1y2" << endl << endl
				<< "unset output" << endl;

		if ( ui->invokeGnuplotCheckbox->isChecked() )
		{
			QString command = QString("gnuplot ") + gnuplotFilename;
			system(command.toStdString().c_str());
		}
	}
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    checkDialog c;
    c.show();

    // shortcuts
    ui->actionOpen->setShortcut(Qt::Key_O | Qt::CTRL);
    ui->actionChange_directory->setShortcut(Qt::Key_D | Qt::CTRL);
    ui->actionClose->setShortcut(Qt::Key_Q | Qt::CTRL);
    ui->actionRun_F5->setShortcut(Qt::Key_F5);
    ui->actionClear_case_F6->setShortcut(Qt::Key_F6);
    ui->actionWrite_input_file_F4->setShortcut(Qt::Key_F4);
    ui->actionCheck->setShortcut(Qt::Key_F7);
    QSignalMapper *signalMapper = new QSignalMapper(this);
    for( int index=0; index < ui->output->count() ; ++index ){
        QShortcut *shortcut  =new QShortcut( QKeySequence(QString("Ctrl+%1").arg( index +1 ) ), this );
        connect( shortcut, SIGNAL(activated() ), signalMapper, SLOT( map() ) );
        signalMapper->setMapping( shortcut, index );
    }
    connect( signalMapper, SIGNAL(mapped( int )),ui->output, SLOT(setCurrentIndex( int )) );


    // Wave theory
    ui->widget_SF->setVisible(false);
    ui->LorP_ComboBox->setVisible(false);
    ui->widget_waveFile->setVisible(false);
    QRect SFwidget_geo = ui->widget_SF->geometry();
    ui->widget_JONSWAP->setGeometry(SFwidget_geo);
    ui->widget_JONSWAP->setVisible(false);
    ui->widget_waveFile->setGeometry(SFwidget_geo);
    ui->widget_customSpectrum->setVisible(false);
    ui->widget_customSpectrum->setGeometry(SFwidget_geo);

    // About
    ui->aboutText_OCW3dGUI->setVisible(false);
    ui->aboutText_OCW3D_publications->setVisible(false);
    ui->aboutText_OCW3DVersion->setVisible(false);

    // Post processing
    ui->readProgressBar->setVisible(false);
    ui->tableWidget->setColumnCount(6);
    ui->tableWidget->setVisible(false);
    ui->SelectOutput->setEnabled(false);
    ui->convert->setEnabled(false);
    ui->morison_widget->setVisible(false);
    ui->eta_widget->setVisible(false);
    QRect Morison_geo = ui->morison_widget->geometry();
    ui->eta_widget->setGeometry(Morison_geo);
    ui->convertStatus->setVisible(false);

    // Custom grid
    ui->geometry_table->setRowCount(2);
    ui->geometry_table->setVerticalHeaderLabels(QString("x [m];d [m]").split(";"));
    ui->customGridWidget->setVisible(false);

    // set labels
    ui->alpha_label->setText(QString((QChar) 0x03B1));
    ui->beta_label->setText(QString((QChar) 0x03B2));
    ui->gamma_label->setText(QString((QChar) 0x03B3));

    connect(ui->waveType,SIGNAL(currentIndexChanged(int)),this,SLOT(on_waveTheoryChanged(int)));
    connect(ui->storeAscii_onOff,SIGNAL(clicked(bool)),this,SLOT(storeASCII(bool)));
    connect(ui->LorP_ComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(on_waveTheoryChanged()));
    connect(ui->nOutFiles,SIGNAL(valueChanged(int)),this,SLOT(on_outputWidgetChanged(int)));
    connect(ui->OpenDirBrowser,SIGNAL(clicked()),this,SLOT(openWorkDirDialog()));
    connect(ui->selectPPfile,SIGNAL(clicked()),this,SLOT(selectPPfile()));
    connect(ui->run,SIGNAL(clicked()),this,SLOT(run()));
    connect(ui->selectGnuplotFile,SIGNAL(clicked()),this,SLOT(openFileDialog()));
    connect(ui->plot,SIGNAL(clicked()),this,SLOT(gnuplot()));
    connect(ui->read_bottom,SIGNAL(clicked()),this,SLOT(readKinematicFile()));
    connect(ui->about_combobox,SIGNAL(currentIndexChanged(int)),this,SLOT(about_changed(int)));
    connect(ui->SelectOutput,SIGNAL(currentIndexChanged(int)),this,SLOT(convertTo_setup(int)));
    connect(ui->convert,SIGNAL(clicked()),this,SLOT(convertTo()));
    connect(ui->showGrid,SIGNAL(clicked()),this,SLOT(showGrid()));
    connect(ui->geometryType,SIGNAL(currentIndexChanged(int)),this,SLOT(geometryType_changed(int)));
    connect(ui->nGridPoints,SIGNAL(valueChanged(int)),this,SLOT(nGridPoints_changed()));
    connect(ui->smooth,SIGNAL(clicked()),this,SLOT(smooth()));
    connect(ui->generateGrid,SIGNAL(clicked()),this,SLOT(generateGrid()));
    connect(ui->selectWaveFile,SIGNAL(clicked()),this,SLOT(selectWaveFile()));
    connect(ui->selectGridFile,SIGNAL(clicked()),this,SLOT(selectGridFile()));
    connect(ui->selectWaveFile_eta,SIGNAL(clicked()),this,SLOT(selectWaveFile_eta()));
    connect(ui->DropDownListOutputType,SIGNAL(currentIndexChanged(int)),this,SLOT(WaveTypeSelected()));
    connect(ui->pushButton_advancedMorison,SIGNAL(clicked()),this,SLOT(advancedMorison()));
    // default
    connect(ui->checkBox_constantWidget,SIGNAL(stateChanged(int)),this,SLOT(constantWidget()));
    connect(ui->checkBox_breakingWidget,SIGNAL(stateChanged(int)),this,SLOT(breakingWidget()));
    connect(ui->checkBox_FD,SIGNAL(stateChanged(int)),this,SLOT(FDWidget()));
    connect(ui->checkBox_precon,SIGNAL(stateChanged(int)),this,SLOT(preconWidget()));

    // ations
    connect(ui->actionClose,SIGNAL(triggered()),this,SLOT(close()));
    connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(openFile()));
    connect(ui->actionRun_F5,SIGNAL(triggered()),this,SLOT(run()));
    connect(ui->actionClear_case_F6,SIGNAL(triggered()),this,SLOT(clearCase()));
    connect(ui->actionWrite_input_file_F4,SIGNAL(triggered()),this,SLOT(writeInputFile()));
    connect(ui->actionChange_directory,SIGNAL(triggered()),this,SLOT(openWorkDirDialog()));
    connect(ui->actionCheck,SIGNAL(triggered()),this,SLOT(checkCase()));
    ui->workingDir->setText(dir.currentPath());

    // Special versions

#if externalOutputClass
    ui->SelectOutput->addItem("External output");
#endif


}
예제 #10
0
파일: libglue.c 프로젝트: agaurav/QT-GRETL
int matrix_command_driver (int ci, 
			   const int *list, 
			   const char *param,
			   const DATASET *dset, 
			   gretlopt opt,
			   PRN *prn)
{
    gretl_matrix *m = NULL;
    DATASET *mdset = NULL;
    int *collist = NULL;
    const char *mname;
    int err = 0;

    mname = get_optval_string(ci, OPT_X);

    if (mname != NULL) {
	m = get_matrix_by_name(mname);
    }

    if (gretl_is_null_matrix(m)) {
	err = E_DATA;
    } else if (ci == SCATTERS) {
	/* note: this is a special case, for now */
	return matrix_scatters(m, list, dset, opt);
    } else if (list != NULL && list[0] == 0) {
	/* use all columns of the matrix */
	mdset = gretl_dataset_from_matrix(m, NULL, OPT_B, &err);
    } else if (list != NULL && list[0] == 1 && ci == SUMMARY) {
	/* summary stats for a single specified column */
	mdset = gretl_dataset_from_matrix(m, list, OPT_B | OPT_N, &err);
    } else {
	/* note that a NULL list is OK here */
	mdset = gretl_dataset_from_matrix(m, list, OPT_B, &err);
    }

    if (!err) {
	dataset_set_matrix_name(mdset, mname);
	collist = gretl_consecutive_list_new(1, mdset->v - 1);
	if (collist == NULL) {
	    err = E_ALLOC;
	}
    }

    if (!err) {
	opt &= ~OPT_X;
	if (ci == BXPLOT) {
	    err = boxplots(collist, param, mdset, opt);
	} else if (ci == GNUPLOT) {
	    err = gnuplot(collist, param, mdset, opt);
	} else if (ci == SUMMARY) {
	    err = list_summary(collist, 0, mdset, opt, prn);
	} else {
	    err = E_DATA;
	}
    }

    destroy_dataset(mdset);   
    free(collist);

    return err;
}