5)注意addpath ('File --> Set path')。如果想让自己的函数成为库函数,需要进行set path操作。注意文件名不要太普通,否则容易重名。
========= 以下是源文件,备查=========
% function A = raw2mat()
[fname,fpath] = uigetfile('D:My documentsMATLABasuCamera*.raw','Pick an RAW file.'); fid = fopen([fpath '' fname]); A = fread(fid); A = A';
%%Acquire File Information x = sum(A(49:52).*[1 2^8 2^16 2^24]); %Width of image; y = sum(A(53:56).*[1 2^8 2^16 2^24]); %Length of image; z = sum(A(21:24).*[1 2^8 2^16 2^24]); %Number of images.
[lyear,lmonth,lday] = unixsecs2date(sum(A(41:44).*[1 2^8 2^16 2^24])); fprintf('=========== RAW file information: =========n'); fprintf('====Captured on %d-%d-%d.n====Size: %dx%dx%d.n',lyear,lmonth,lday,x,y,z);
%%Acquire Index information for each image
B = zeros(x,y,z,'uint16');
index0 = sum(A(33:36).*[1 2^8 2^16 2^24]); %The offset of a block that stores the offsets of each image.