-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathedit_data.m
66 lines (55 loc) · 1.62 KB
/
edit_data.m
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
61
62
63
64
65
66
function [ref_data, sensor_data] = edit_data(ref_data, sensor_data, fig_handle)
%%EDIT_DATA handles if the user wants to add or remove outliers from the
%%data.
%
% MIT License
% Copyright (c) <2023> <Jesper Løve Hinrich>
if nargin < 1
ref_data=randn(10,1);
sensor_data = randn(10,1);
end
if nargin < 3
fig_handle = figure;
end
uit = uitable(fig_handle);
if length(ref_data)==length(sensor_data)
uit.Data =[ref_data,sensor_data, ref_data-sensor_data];
uit.ColumnName = {'Reference Data', 'Sensor Data', 'Difference'};
else
uit.Data =[sensor_data];
uit.ColumnName = {'Sensor Data'};
end
set(fig_handle,'CloseRequestFcn',@MyReturnData);
uit.ColumnEditable = true;
set(fig_handle,'Tag','editFig')
set(uit,'Tag','editTable')
set(uit,'Position',[10,10,uit.Parent.Position(3:4).*[0.7, 0.9] ])
figure(fig_handle)
newData =[];
txt_title = uicontrol('Style', 'text', 'Position', [10 uit.Parent.Position(4)*0.92 uit.Parent.Position(3)*0.8 30], 'String', 'Edit the current dataset by changing the value of the cells.');
txt_title.FontSize=14;
waitfor(fig_handle);
% end
% Return edited data
if length(ref_data)==length(sensor_data)
ref_data = newData(:,1);
sensor_data = newData(:,2);
else
sensor_data = newData(:,1);
end
% end
function MyReturnData(~,~)
myfigure=findobj('Tag','editFig');
newData=get(findobj(myfigure,'Tag','editTable'),'Data');
% ref_data = uit.Data(:,1);
% sensor_data = uit.Data(:,2);
delete(myfigure);
end
end
%% Highlight outliers
%
% styleIndices = ismissing(tdata);
% [row,col] = find(styleIndices);
%
% s = uistyle('BackgroundColor','yellow');
% addStyle(uit,s,'cell',[row,col]);