-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_data.m
More file actions
60 lines (60 loc) · 1.96 KB
/
plot_data.m
File metadata and controls
60 lines (60 loc) · 1.96 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
% This script will make a plot of accuracy and norm of difference matrices for each timepoint.
function [data] = plot_data(file_name, typeoutput)
key = '';
%data = zeros(numpoints, numnodes);
valid = ['NormDiff', 'NormDiffNormal', 'Accuracy'];
if size(file_name) == 0
file_name = 'C:\Users\Ashutosh\Documents\GitHub\DistributedMulticlassSolver\DistributedMulticlassSVMSolver\output.txt';
end
if isfloat(typeoutput)
if !(round(typeoutput) == typeoutput) || !isscalar(typeoutput)
%Second thing is size of the size of the stuff isn't the same (different number of dimensions)
%Third thing is that it has to be [1 1] (If we didn't have it, any 2D matrixo could sneak by)
disp(sprintf('Type output not an integer! Value: %f\n', typeoutput))
return
end
if typeoutput == 0
key = 'NormDiff';
elseif typeoutput == 1
key = 'NormDiffNormal';
else
key = 'Accuracy';
end
elseif ischar(typeoutput)
key = typeoutput;
if sum(strfind(valid, key)) == 0
disp(sprintf('Invalid typeoutput specification: %s!', key))
return
end
else
disp(sprintf('Unrecognized class type for typeoutput: %s!', class(typeoutput)))
return
end
disp(key)
file = fopen(file_name);
line = fgetl(file);
index = 1;
while ischar(line)
concatenated = sprintf('Node: %%d; Timepoint: %%d; %s: %%f', key);
A = sscanf(line, concatenated)';
if size(A) == [1 3]
data(A(2) + 1, A(1) + 1) = A(3);
end
line = fgetl(file);
index = index + 1;
end
for i = 1:size(data)(2)
disp(i)
X = linspace(1, size(data)(1), size(data)(1));
Y = data(X, i);
figure;
fig = plot(X,Y);
title(sprintf('Norm Diff (Percent) Plot For Node %d', i))
ylabel(sprintf("Frobenius Norm for Difference Matrix Percent at Node %d", i))
xlabel("Number of Cycles in PeerSim")
axis([0 size(data)(1) 0 1])
h = gcf;
filename = sprintf("C:\\Users\\Ashutosh\\Dropbox\\School\\Eleventh Grade\\Columbia Internship\\Data Analysis\\NormDiffPercent Plot for Node %d.jpg", i);
saveas(h, sprintf("NormDiffPercentPlotForNode%d.jpg", i))
%saveas(h, filename)
end