You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rank argument specifies how many dimensions the data has. The minimum rank is 2.
The below program sets rank=1 and dims[1] = {1}. When compiled and run with
% cc -o z b.c -I/usr/local/include -L/usr/local/lib -lmatio -lz
% ./z z.mat
the file z.mat loaded into octave contains the right variable and value. Is the documentation wrong?
#include <err.h>
#include <stdlib.h>
#include <stdio.h>
#include "matio.h"
#define COMP MAT_COMPRESSION_NONE
void
write_float_scalar(mat_t *mfp, char *xnam, float *xval)
{
matvar_t *mvar;
int rank = 1; // Should a run-time error occur because rank = 1?
size_t dims[1] = {1};
mvar = Mat_VarCreate(xnam, MAT_C_SINGLE, MAT_T_SINGLE, rank, dims, xval, 0);
if (!mvar)
errx(1, "creating variable: %s", xnam);
Mat_VarWrite(mfp, mvar, COMP);
Mat_VarFree(mvar);
}
int
main(int argc, char *argv[])
{
mat_t *mfp;
matvar_t *mvar;
int i,j;
float a;
size_t dims[2];
if (argc != 2)
errx(1,"Usage: a filename");
mfp = Mat_CreateVer(*++argv, NULL, MAT_FT_MAT5);
if (!mfp)
errx(1, "cannot create %s", *argv);
a = 42;
write_float_scalar(mfp, "a", &a);
Mat_Close(mfp);
return 0;
}
The text was updated successfully, but these errors were encountered:
kargl
changed the title
Mat_VarCreate states minim rank is 2, but 1 seems to work.
Mat_VarCreate states minimum rank is 2, but 1 seems to work.
Oct 31, 2024
The manual page contains
The below program sets
rank=1
anddims[1] = {1}
. When compiled and run withthe file z.mat loaded into octave contains the right variable and value. Is the documentation wrong?
The text was updated successfully, but these errors were encountered: