MATLAB: How to convert files on the workspace to mat file ?

#face recognition

I have a file on my workspace named effLBP containing extracted feature It's a 592*896*3uint8 matrix
1. How do I convert this file to .mat file ??
2.How do I convert the .mat file to csv or arff file format?
Please help.
Thanks

Best Answer

To load the uint8 data you need to know what order it was written in. The basic setup is
fid = fopen('effLBP.dat', 'r');
data = fread(fid, 592*896*3, '*uint8');
fclose(fid);
After that you have to start re-arranging the data until it makes sense, such as
data123 = reshape(data, 592, 896, 3);
data213 = permute(reshape(data, 896, 592, 3), [2 1 3]);
data132 = permute(reshape(data, 592, 3, 896), [1 3 2]);
data321 = permute(reshape(data, 3, 896, 592), [3 2 1]);
and see which one looks right when you image() it.