Sample program: |
The following code lets you select a MatLab file. If the selected MatLab file is stored in MatLab 4 format, the first matrix of the file is loaded into the variable DataMat and printed:
program readml4;
var
FName : string;
fs : TMixedFStream;
datamat : TDouble2DArray;
offsets : TIntArray;
nMats : integer;
MatName : string;
begin
FName := SelectFile ('', '*.mat', 'Please select a MatLab 4 file');
if FName <> '' then
begin
fs := TMixedFStream.Create (FName, fmOpenRead);
NMats := CountML4Matrices (fs, Offsets);
if NMats > 0 then
begin
LoadML4Matrix(fs, Offsets[0], datamat, MatName);
cout ('DataMat: ', datamat);
end;
fs.Free;
end;
end.
|