%%%%%%%%%%%%%%%%%%%%%%%% % lambo-ryd-uni %%%%%%%%%%%%%%%%%%%%%%%% min_x = min(small_dataset2(:,2)); min_y = min(small_dataset2(:,1)); max_x = max(small_dataset2(:,2)); max_y = max(small_dataset2(:,1)); length_x = max_x - min_x; length_y = max_y - min_y; % Distance in meters for x and y axis meter_x = distanceGPS(min_y,min_x,min_y,max_x); meter_y = distanceGPS(min_y,min_x,max_y,min_x); div_x = meter_x/10; div_y = meter_y/10; row_num_=333; column_num=174; distance_x_10 = length_x/row_num_; distance_y_10 = length_y/column_num; counter = 0; max_cell_size = 0; min_cell_size = 1000; number_of_cells_not_conforming_to_std = 0; cells_within_std = ones(row_num,column_num); cells_std = zeros(row_num,column_num); cells_with_data = 0; cells_number_of_points = zeros(row_num,column_num); cells_no_data = 0; cell_max_row = 0; cell_max_column = 0; cell_min_row = 0; cell_min_column = 0; for row=1:1:row_num_ last_row_value = min_y + ((row - 1)* distance_y_10); if row == row_num_ next_row_value = max_y + 1; else next_row_value = min_y + (row * distance_y_10); end for column=1:1:column_num last_column_value = min_x + ((column - 1)* distance_x_10); if column == column_num next_column_value = max_x + 1; else next_column_value = min_x + (column * distance_x_10); end temp = small_dataset2(small_dataset2(:,1)>=(min_y + ((row-1)*distance_y_10)) ... & small_dataset2(:,1)<=(min_y + row*distance_y_10) & ... small_dataset2(:,2)>=(min_x + ((column-1)*distance_x_10)) ... & small_dataset2(:,2)<=(min_x + column*distance_x_10) ... & small_dataset2(:,4)<=100,1:4); % isempty returns 1 if true and 0 for false if isempty(temp) == 0 cells_with_data = cells_with_data + 1; weighted_cells{(row-1)*column_num + column} = temp; cells_std(row,column) = std(temp(:,3)); counter = counter + length(temp); cells_number_of_points(row,column) = length(temp); if length(temp) > max_cell_size max_cell_size = length(temp); cell_max_row = row; cell_max_column = column; end if length(temp) < min_cell_size min_cell_size = length(temp); cell_min_row = row; cell_min_column = column; end if row == 54 && column == 147 cell_max_rss = temp(:,3); cell_max_acc = temp(:,4); end if row == 52 && column == 144 cell_min_rss = temp(:,3); end if row == 55 && column == 143 cell_high_rss = temp(:,3); end else weighted_cells{(row-1)*column_num + column} = []; cells_no_data = cells_no_data + 1; end end end %%%%%%%%%%%%%%%%%%%%%%%%%%%% % Weight the data cells %%%%%%%%%%%%%%%%%%%%%%%%%%%% weighted_rss = zeros(row_num,column_num); weighted_acc = zeros(row_num,column_num); weighted_std = zeros(row_num,column_num); weighted_energy = zeros(row_num,column_num); for row=1:1:row_num for column=1:1:column_num temp = weighted_cells{(row-1)*column_num + column}; weighted_values = []; if isempty(temp) == 0 temp_max = max(temp(:,4))+1; for i=1:1:length(temp(:,4)) % (max - x)^2 % where x = error margin of data point accuracy = temp(i:i,4); %if accuracy < 100 rss = (temp(i:i,3)); weight = (temp_max-accuracy+1)^2; weight_value = weight*rss; weighted_values = [weighted_values; accuracy weight weight_value]; %end end if isempty(weighted_values) == 0 weighted_acc(row,column) = median(temp(:,4)); weighted_rss(row,column) = sum(weighted_values(:,3)) / sum(weighted_values(:,2)); weighted_std(row,column) = std(weighted_values(:,3)); strength = weighted_rss(row,column); if strength >= -84 weighted_energy(row,column) = 1; elseif strength >= -95 weighted_energy(row,column) = 2; else weighted_energy(row,column) = 3; end end end weighted_map{(row-1)*column_num + column} = weighted_values; end end %%%%%%%%%%%%%%%%%%%%%%%%%%%% % Plots %%%%%%%%%%%%%%%%%%%%%%%%%%%% figure(91); imagesc(weighted_rss) colorbar(); figure(92); imagesc(weighted_energy) colorbar(); %%%%%%%%%%%% % Small path for RSS %%%%%%%%%%% % Choosen rows and columns from lambo_uni data set for small path % (x,y) % 124,30 % 152,83 figure(93); imagesc(weighted_rss2) colorbar(); figure(94); imagesc(weighted_rss2_compare) colorbar(); %%%% % Indexes with path, in order %%%%%%%%% % 15,21; % 14,23:30; % 13,31:32; % 12,33; % 11,34; % 10,35; % 9,35:44; start_row = 29; start_column = 123; % The collected path rounded, in order, per square collected_path_rss = [-100;-97;-95;-95;-95;-97;-93;-97;-99;-91;-87;-87;-89;-87;-93;-93;-93;-89;-91;-91;-91;-85;-85;-85]; % Weighted RSS for the path in order small_path_rss = [weighted_rss(21+start_row,15+start_column); ... weighted_rss((23+start_row):(30+start_row),14+start_column); ... weighted_rss((31+start_row):(32+start_row),13+start_column); ... weighted_rss((33+start_row),12+start_column); ... weighted_rss((34+start_row),11+start_column); ... weighted_rss((35+start_row),10+start_column); ... weighted_rss((35+start_row):(44+start_row),9+start_column) ... ]; %array(1..8, i = i^2 $ i = 1..8) %small_path = zeroes(24); small_path_nr= [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]; % STD of the squares on the path in order small_path_std = [cells_std(21+start_row,15+start_column); ... cells_std((23+start_row):(30+start_row),14+start_column); ... cells_std((31+start_row):(32+start_row),13+start_column); ... cells_std((33+start_row),12+start_column); ... cells_std((34+start_row),11+start_column); ... cells_std((35+start_row),10+start_column); ... cells_std((35+start_row):(44+start_row),9+start_column) ... ]; % Accuracy for the path in order small_path_acc = [weighted_acc(21+start_row,15+start_column); ... weighted_acc((23+start_row):(30+start_row),14+start_column); ... weighted_acc((31+start_row):(32+start_row),13+start_column); ... weighted_acc((33+start_row),12+start_column); ... weighted_acc((34+start_row),11+start_column); ... weighted_acc((35+start_row),10+start_column); ... weighted_acc((35+start_row):(44+start_row),9+start_column) ... ]; % Accuracy for the path in order weighted_cells{(row-1)*column_num + column} all_in_squares_path_acc = [weighted_cells{(21+start_row-1)*column_num + (15+start_column)}(:,4); ... weighted_cells{(23+start_row-1)*column_num + (14+start_column)}(:,4); ... weighted_cells{(24+start_row-1)*column_num + (14+start_column)}(:,4); ... weighted_cells{(25+start_row-1)*column_num + (14+start_column)}(:,4); ... weighted_cells{(26+start_row-1)*column_num + (14+start_column)}(:,4); ... weighted_cells{(27+start_row-1)*column_num + (14+start_column)}(:,4); ... weighted_cells{(28+start_row-1)*column_num + (14+start_column)}(:,4); ... weighted_cells{(29+start_row-1)*column_num + (14+start_column)}(:,4); ... weighted_cells{(30+start_row-1)*column_num + (14+start_column)}(:,4); ... weighted_cells{(31+start_row-1)*column_num + (13+start_column)}(:,4); ... weighted_cells{(32+start_row-1)*column_num + (13+start_column)}(:,4); ... weighted_cells{(33+start_row-1)*column_num + (12+start_column)}(:,4); ... weighted_cells{(34+start_row-1)*column_num + (11+start_column)}(:,4); ... weighted_cells{(35+start_row-1)*column_num + (10+start_column)}(:,4); ... weighted_cells{(35+start_row-1)*column_num + (9+start_column)}(:,4); ... weighted_cells{(36+start_row-1)*column_num + (9+start_column)}(:,4); ... weighted_cells{(37+start_row-1)*column_num + (9+start_column)}(:,4); ... weighted_cells{(38+start_row-1)*column_num + (9+start_column)}(:,4); ... weighted_cells{(39+start_row-1)*column_num + (9+start_column)}(:,4); ... weighted_cells{(40+start_row-1)*column_num + (9+start_column)}(:,4); ... weighted_cells{(41+start_row-1)*column_num + (9+start_column)}(:,4); ... weighted_cells{(42+start_row-1)*column_num + (9+start_column)}(:,4); ... weighted_cells{(43+start_row-1)*column_num + (9+start_column)}(:,4); ... weighted_cells{(44+start_row-1)*column_num + (9+start_column)}(:,4); ... ]; % RSS for the path in order weighted_cells{(row-1)*column_num + column} all_in_squares_path_rss = [weighted_cells{(21+start_row-1)*column_num + (15+start_column)}(:,3); ... weighted_cells{(23+start_row-1)*column_num + (14+start_column)}(:,3); ... weighted_cells{(24+start_row-1)*column_num + (14+start_column)}(:,3); ... weighted_cells{(25+start_row-1)*column_num + (14+start_column)}(:,3); ... weighted_cells{(26+start_row-1)*column_num + (14+start_column)}(:,3); ... weighted_cells{(27+start_row-1)*column_num + (14+start_column)}(:,3); ... weighted_cells{(28+start_row-1)*column_num + (14+start_column)}(:,3); ... weighted_cells{(29+start_row-1)*column_num + (14+start_column)}(:,3); ... weighted_cells{(30+start_row-1)*column_num + (14+start_column)}(:,3); ... weighted_cells{(31+start_row-1)*column_num + (13+start_column)}(:,3); ... weighted_cells{(32+start_row-1)*column_num + (13+start_column)}(:,3); ... weighted_cells{(33+start_row-1)*column_num + (12+start_column)}(:,3); ... weighted_cells{(34+start_row-1)*column_num + (11+start_column)}(:,3); ... weighted_cells{(35+start_row-1)*column_num + (10+start_column)}(:,3); ... weighted_cells{(35+start_row-1)*column_num + (9+start_column)}(:,3); ... weighted_cells{(36+start_row-1)*column_num + (9+start_column)}(:,3); ... weighted_cells{(37+start_row-1)*column_num + (9+start_column)}(:,3); ... weighted_cells{(38+start_row-1)*column_num + (9+start_column)}(:,3); ... weighted_cells{(39+start_row-1)*column_num + (9+start_column)}(:,3); ... weighted_cells{(40+start_row-1)*column_num + (9+start_column)}(:,3); ... weighted_cells{(41+start_row-1)*column_num + (9+start_column)}(:,3); ... weighted_cells{(42+start_row-1)*column_num + (9+start_column)}(:,3); ... weighted_cells{(43+start_row-1)*column_num + (9+start_column)}(:,3); ... weighted_cells{(44+start_row-1)*column_num + (9+start_column)}(:,3); ... ]; % Accuracy for the path per square in order weighted_cells{(row-1)*column_num + column} per_squares_path_rss = {weighted_cells{(21+start_row-1)*column_num + (15+start_column)}(:,3) ... weighted_cells{(23+start_row-1)*column_num + (14+start_column)}(:,3) ... weighted_cells{(24+start_row-1)*column_num + (14+start_column)}(:,3) ... weighted_cells{(25+start_row-1)*column_num + (14+start_column)}(:,3) ... weighted_cells{(26+start_row-1)*column_num + (14+start_column)}(:,3) ... weighted_cells{(27+start_row-1)*column_num + (14+start_column)}(:,3) ... weighted_cells{(28+start_row-1)*column_num + (14+start_column)}(:,3) ... weighted_cells{(29+start_row-1)*column_num + (14+start_column)}(:,3) ... weighted_cells{(30+start_row-1)*column_num + (14+start_column)}(:,3) ... weighted_cells{(31+start_row-1)*column_num + (13+start_column)}(:,3) ... weighted_cells{(32+start_row-1)*column_num + (13+start_column)}(:,3) ... weighted_cells{(33+start_row-1)*column_num + (12+start_column)}(:,3) ... weighted_cells{(34+start_row-1)*column_num + (11+start_column)}(:,3) ... weighted_cells{(35+start_row-1)*column_num + (10+start_column)}(:,3) ... weighted_cells{(35+start_row-1)*column_num + (9+start_column)}(:,3) ... weighted_cells{(36+start_row-1)*column_num + (9+start_column)}(:,3) ... weighted_cells{(37+start_row-1)*column_num + (9+start_column)}(:,3) ... weighted_cells{(38+start_row-1)*column_num + (9+start_column)}(:,3) ... weighted_cells{(39+start_row-1)*column_num + (9+start_column)}(:,3) ... weighted_cells{(40+start_row-1)*column_num + (9+start_column)}(:,3) ... weighted_cells{(41+start_row-1)*column_num + (9+start_column)}(:,3) ... weighted_cells{(42+start_row-1)*column_num + (9+start_column)}(:,3) ... weighted_cells{(43+start_row-1)*column_num + (9+start_column)}(:,3) ... weighted_cells{(44+start_row-1)*column_num + (9+start_column)}(:,3) ... }; % Plot figure(88); %plot(collected_path_rss,'-ro'); hold on; plot(small_path_rss,'-bx'); errorbar(1:1:24,small_path_rss,small_path_std); %plot(small_path_std,'-bs'); hold off; legend('Collected','STD','Signal Map'); small_list = zeros(254); for i=1:1:254 a = mod(i,24); small_list(i) = a; end % small_match_cells = []; % small_match_per_square = {}; % for i=1:1:24 % if i == 1 % small_match_per_square{i} = [-100; -100; -100; -100; -100; small_path_rss(i)]; % elseif i == 24 % small_match_per_square{i} = [small_path_rss(i); -85; -85; -85 ;-85; -85 ;-85 ;-85 ;-85 ;-85]; % else % small_match_per_square{i} = small_path_rss(i); % end % if i == 24 % small_match_cells = [-100; -100; -100; -100; -100 ;small_match_cells; -85; -85; -85 ;-85; -85 ;-85 ;-85 ;-85 ;-85]; % else % small_match_cells = [small_match_cells; small_path_rss(i)]; % end % end % % % smallpath_rss = smallpath(:,3); % smallpath_accuracy = smallpath(:,4); % % [rof,pof] = corrcoef(small_match_cells,smallpath_rss); % [r,p] = corr(small_match_cells,smallpath_rss); % P1 21+start_row,15+start_column % P2 154,106 %%%%%%%%%%%%%%%%%