MATLAB: How to convert .mat to .txt

MATLAB

hi.. i have one .mat file which contain 5 class. each class has 1X20000 matrix. how to convert all of them(5classes) inside the .mat into 1 single .txt file. ive tried below coding, but it can only convert class1 only..i want all of the class. how to create the loop so that it will convert all of the class.
load('data_CombineFaceFinger.mat')
dlmwrite('data_CombineFaceFinger.txt', class1)
please see my attachment..

Best Answer

C={class1,class2,class3,class4,class5};
CLASS = cat(1,C{:});
dlmwrite('data_CombineFaceFinger.txt',CLASS,'delimiter',' ') % creates 5 X 20000 matrix
dlmwrite('data_CombineFaceFinger1.txt',CLASS.','delimiter',' ') % creates 20000 X 5 matrix
Related Question