summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/svm/src/matlab/readMatrix.m
blob: fe684c5cb6380d1813ea878530b67970a08763ba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function readMatrix(srcImage, outName)

write = fopen([outName '.m'], 'w');

count = fwrite(write, 'function out = ');
count = fwrite(write, outName);
fprintf(write, '\n');
count = fwrite(write, 'out = [...');
fprintf(write, '\n');    

height = size(srcImage,1);
width = size(srcImage,2);

for nI=1:height
    for nJ=1:width
        fprintf(write, '%f ', srcImage(nI,nJ));
    end
    if(nI < height)
        fprintf(write, ';...\n');
    end
end

fprintf(write, '...\n');
count = fwrite(write, '];');

fclose(write);

end