-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_data.m
More file actions
66 lines (50 loc) · 1.25 KB
/
get_data.m
File metadata and controls
66 lines (50 loc) · 1.25 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
61
62
63
64
65
66
function [ data, filename] = get_data( )
[filename path] = uigetfile('*.*');
if (path == 0)
error(['file not selected' ' :-(']);
exit
end
filepath = [path filename]
[fid,msg] = fopen(filepath,'r');
if (fid<0)
error(['Cannot open ' filename]);
exit
end
%
%
% % God(:,row) = reshape(temp, 120, 1);
%
fprintf('file (%s) opened successfully\n', filename);
%%% Uncomment this for STSP
%%%<<<<<<
% % % file_data = fscanf(fid,'%g %g', [3 inf]);
% % % file_data = file_data';
% % %
% % % row = size(file_data,1);
% % %
% % % TSP = zeros(row,row);
% % %
% % % for (i = 1:row)
% % % for (j = 1:row)
% % % TSP(i,j) = sqrt((file_data(i,2)-file_data(j,2))^2 + (file_data(i,3)-file_data(j,3))^2);
% % % end
% % % end
%%%>>>>>>>
%%%% Uncomment following for ATSP
%%<<<<
row = fscanf(fid,'%d',1);
format = '';
for (i = 1:row)
format = [format ' %g'];
end
file_data = fscanf(fid,format, [row inf]);
file_data = file_data';
TSP = file_data;
%%>>>>>
% % % % % % % Testing data % % %% % % % % % %% % %%
% read file abc.txt then do the following
% temp = fscanf(fid,'%d %d %d %d %d', [5 4]);
% God = temp;
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
fclose(fid);
data = TSP;