Hi Statalist users,
I have a question about matuse/matsave and fputmatrix/fgetmatrix using Stata 14. Are these two not compatible to each other? Implying that a file saved with matsave can not be processed using fgetmatrix? The background of my problem is, that I would like to add a matrix to an existing .mmat file with an undefined number of matrices already saved in it.
For example:
Mata is not able to perform the line "B = fgetmatrix(fh)" with the error: "fgetmatrix(): 610 file format error" and the line "mata mata matuse "test.mmat"" aborts with the error "file test.mmat not .mmat-format file" (error code 610 as well).
My understanding from the helpfile for mata matsave is, that both are compatible to each other. Also I had a look into the sourcecode for matsave and my understanding is that matsave uses fputmatrix to save matrices.
So my question is, are these two completely different or is there somewhere a mistake in my code?
Thanks!
Jan
I have a question about matuse/matsave and fputmatrix/fgetmatrix using Stata 14. Are these two not compatible to each other? Implying that a file saved with matsave can not be processed using fgetmatrix? The background of my problem is, that I would like to add a matrix to an existing .mmat file with an undefined number of matrices already saved in it.
For example:
Code:
clear all mataA = rnormal(2,2,0,1) B = rnormal(3,3,0,1) mata matsave "test.mmat" A B , replaceend clear mata mataC = rnormal(4,4,0,1) fh = fopen("test.mmat", "rw") fputmatrix(fh, C) fclose(fh)end clear mata matafh = fopen("test.mmat", "r") C = fgetmatrix(fh) B = fgetmatrix(fh) A = fgetmatrix(fh) fclose(fh)end clear mata mata mata matuse "test.mmat"
My understanding from the helpfile for mata matsave is, that both are compatible to each other. Also I had a look into the sourcecode for matsave and my understanding is that matsave uses fputmatrix to save matrices.
So my question is, are these two completely different or is there somewhere a mistake in my code?
Thanks!
Jan
Comment