Data blob variable

조회 수: 2 (최근 30일)
Mike
Mike 2011년 9월 13일
My goal is to pass a blob of data out of a function that contains a .mat file. Currently I can get close to the desired behavior with the following snippet.
save('functionspace_data.mat');
fid = fopen('functionspace_data.mat');
blob = fread(fid, inf, '*uint8');
But I need to do a similar thing without the use of files in the middle of the code. The format of the blob does not need to be .mat, but does have to be in a format that when converted to a file can quickly reload my function space.
Thanks in advance, Mike

답변 (1개)

Walter Roberson
Walter Roberson 2011년 9월 13일
Please vote for the suggestion to expose the serialization routines, http://www.mathworks.com/matlabcentral/answers/1325-what-is-missing-from-matlab#answer_2153 here.
The ease of hacking it yourself depends on what kind of data structures you want to be able to use. Objects and handles are the most difficult; plain numeric arrays can be fairly easy.
Some of the bundling and unbundling work for structures can be done by memmapfile(), but I suspect that might be tend to be on the slower side.
  댓글 수: 2
Mike
Mike 2011년 9월 14일
Based on us asking for this in the "what is missing from matlab" forum. I assume there is not really a clean way of doing this without the use of a intermediate file. Thats unfortunate.
Walter Roberson
Walter Roberson 2011년 9월 14일
Yup. The closest I've seen is that R2011a (I think it was) introduced a method of serializing graphics files for transmission -- but that was part of the MATLAB Coder tool for generating C code such as for embedded systems.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by