-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopt_task1_script.m
More file actions
49 lines (43 loc) · 2.63 KB
/
Copy pathopt_task1_script.m
File metadata and controls
49 lines (43 loc) · 2.63 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
clc; clear; close all;
format long
dir_path = "E:\VScode\metod_optim\matlab\task12 merged\"; % File's directory
file_names1 = ["BULK_1.txt" "BULK_2.txt" "BULK_3.txt" "BULK_4.txt" "BULK_5.txt"]; % Names of data files (task 1)
file_names2 = ["BULK_LARGE.txt" "BULK_12.txt" "BULK_22.txt" "BULK_32.txt" "BULK_42.txt" "BULK_52.txt"]; % Names of data files (task 2)
%% Task 1
for i = 1:length(file_names1)
file_path = strcat(dir_path, file_names1(i)); % Building absolute path to data file
f = @() opt_task1_fun(file_path); % Function handler for estimating run time for each data file [sec]
t1{i} = timeit(f); % Estimating run time for each data file [sec]
[Ufact1{i}, Ucalc1{i}, error1{i}] = opt_task1_fun(file_path); % Temperature and error calculation
end
errors1 = cell2mat(error1); % Calculation error for each data file
delete 'console1.txt';
diary ('E:\VScode\metod_optim\matlab\task12 merged\console1.txt')
for i = 1:length(file_names1)
disp(sprintf('For the file %s', file_names1(i)));
disp(sprintf('Estimated temperature'));
disp(sprintf('%3f ',cell2mat(Ucalc1(i))));
disp(sprintf('Discrepancy %3f ',errors1(i)));
disp(sprintf('Execution time %3f per second',cell2mat(t1(i))));
disp(' ');
end
diary off
%% Task 2
for i = 1:length(file_names2)
file_path = strcat(dir_path, file_names2(i)); % Building absolute path to data file
f = @() opt_task1_fun(file_path); % Function handler for estimating run time for each data file [sec]
t2{i} = timeit(f); % Estimating run time for each data file [sec]
[Ufact2{i}, Ucalc2{i}, error2{i}] = opt_task1_fun(file_path); % Temperature and error calculation
end
errors2 = cell2mat(error2);
delete 'console2.txt';
diary ('E:\VScode\metod_optim\matlab\task12 merged\console2.txt')
for i = 1:length(file_names2)
disp(sprintf('For the file %s', file_names2(i)));
disp(sprintf('Estimated temperature'));
disp(sprintf('%3f ',cell2mat(Ucalc2(i))));
disp(sprintf('Discrepancy %3f ',errors2(i)));
disp(sprintf('Execution time %3f per second',cell2mat(t2(i))));
disp(' ');
end
diary off