X-Received: by 10.36.89.146 with SMTP id p140mr278829itb.35.1515092195175; Thu, 04 Jan 2018 10:56:35 -0800 (PST) X-Received: by 10.157.51.146 with SMTP id u18mr20578otc.5.1515092194971; Thu, 04 Jan 2018 10:56:34 -0800 (PST) Path: csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!i6no27473itb.0!news-out.google.com!s63ni18itb.0!nntp.google.com!g80no27084itg.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.graphics.apps.gnuplot Date: Thu, 4 Jan 2018 10:56:34 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2602:304:6fc0:d5c0:51dc:2e86:7f77:dea; posting-account=TwWxFQoAAABpNWsJoVrvjxISZB6VzI7X NNTP-Posting-Host: 2602:304:6fc0:d5c0:51dc:2e86:7f77:dea User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8b40094d-fd5c-452e-939d-49710009fa5d@googlegroups.com> Subject: about error message "matrix does not represent a grid" in gnuplot From: Dawn Injection-Date: Thu, 04 Jan 2018 18:56:35 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Lines: 131 Xref: csiph.com comp.graphics.apps.gnuplot:3845 Hi, all: I used fopen in c to read in a data file. I used plot 'data.txt' matri= x with image to plot out the image. However, when I used fopen to write in = the same data set as a new data file and I used same command line with new = data file as: plot 'data1.txt' matrix with image, the image cannot be plott= ed and error message said: matrix does not represent a grid My basic codes are: =20 ------------------------------------------------------ =20 int main() { #ifdef WIN32 FILE *pipe =3D _popen(GNUPLOT_NAME, "w"); #else FILE *pipe =3D popen(GNUPLOT_NAME, "w"); #endif =09 int xsize =3D 20, ysize =3D 41; float **din; // alloc memory din =3D (float **)malloc(sizeof(float *) * ysize); for (int i =3D 0; i < ysize; i++) { din[i] =3D (float *)malloc(sizeof(float) * xsize); =09 } // read in 2D data FILE *fp, *fp1;=09 fp =3D fopen("wedgegas.txt", "r"); fp1 =3D fopen("inversedwedgegas.txt", "w"); =09 // read in data if (fp =3D=3D NULL) { printf("fp is NULL!\n"); exit(1); } for (int i =3D 0; i < ysize; i++) { printf("i=3D%d \n ", i); for (int j =3D 0; j < xsize; j++) { fscanf(fp, "%f ", &din[i][j]); printf("%f ", din[i][j]); } fscanf(fp, "\n"); printf("\n "); } =09 /* write final inversed data to din */ if (fp1 =3D=3D NULL) { printf("fp1 is NULL!\n"); exit(1); } for (int i =3D 0; i < ysize; i++) { printf("%d \n", i); for (int j =3D 0; j < xsize; j++) { =09 fprintf(fp1, "%f ", din[i][j]); printf("%f ", din[i][j]); } fprintf(fp1, "\n"); printf("\n"); } /* ---------------------------- plot results -----------------------------= -------------------------- */ plot: if (pipe !=3D NULL) { // plot sinc wave plot 1=09 fprintf(pipe, "set multiplot layout 1,2 \n"); // set multiple plo= ts =20 fprintf(pipe, "plot 'wedgegas.txt' matrix with image \n"); // plot type = =20 =09 fprintf(pipe, "%s \n", "e"); // termination character, end a = plot fflush(pipe); // flush the pipe =09 =09 fprintf(pipe, "plot 'inversedwedgegas.txt' matrix with image \n"); // plo= t type fprintf(pipe, "%s\n", "e"); // termination character fflush(pipe); // flush the pipe =09 // wait for key press std::cin.clear(); std::cin.ignore(std::cin.rdbuf()->in_avail()); std::cin.get(); #ifdef WIN32 _pclose(pipe); #else=20 pclose(pipe); #endif } else std::cout << "Could not open pipe" << std::endl; fclose(fp); fclose(fp1); return 0; } ------------------------------------------------------------ Any suggestions? Thanks in advance!