Gather all feature variables into one variable and write to an ASCII delimited file.
Code -
feature = [feature1 feature2 feature3 feature4 feature5];
dlmwrite('myfile.txt', '', 'delimiter', '');
for c2 = 1:size(feature,1)
str1=[ num2str(median(feature(c2,:)))];
for c1 = 1:size(feature,2)
str1 =[str1 [' feature',num2str(c1),':' num2str(feature(c2,c1))] ];
end
dlmwrite('myfile.txt', str1, 'delimiter', '','-append');
end
The text file would look like this :
1 feature1:1 feature2:1 feature3:1 feature4:0 feature5:1
0 feature1:0 feature2:1 feature3:0 feature4:1 feature5:-1
0 feature1:1 feature2:0 feature3:0 feature4:1 feature5:-1
0 feature1:0 feature2:0 feature3:0 feature4:1 feature5:1
0 feature1:1 feature2:0 feature3:0 feature4:0 feature5:-1
1 feature1:1 feature2:0 feature3:1 feature4:1 feature5:1
0 feature1:0 feature2:0 feature3:0 feature4:1 feature5:-1
Please confirm if this is what you need!