-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyze.m
More file actions
33 lines (28 loc) · 1.34 KB
/
Copy pathanalyze.m
File metadata and controls
33 lines (28 loc) · 1.34 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
% This compares your Event-Triggered system vs. a Standard Sensor
fixed_interval = 0.01; % Hypothetical sensor sending data every 0.01s (100Hz)
hypothetical_count = t_final / fixed_interval;
actual_count = length(trigger_times);
% If no triggers happened (system very stable), actual_count might be 0
savings = (1 - (actual_count / hypothetical_count)) * 100;
% Display Report
fprintf('\n==================================================\n');
fprintf(' COMMUNICATION SAVINGS ANALYSIS \n');
fprintf('==================================================\n');
fprintf('Total Simulation Time : %.2f sec\n', t_final);
fprintf('Fixed-Rate Sensor (100Hz) : %.0f transmissions\n', hypothetical_count);
fprintf('Event-Triggered (Actual) : %d transmissions\n', actual_count);
fprintf('--------------------------------------------------\n');
fprintf('TOTAL BANDWIDTH SAVED : %.2f %%\n', savings);
fprintf('==================================================\n');
%% 4. Plotting
figure(1);
subplot(2,1,1);
plot(all_t, all_states(:,1:2), 'LineWidth', 1.5);
title('Robot Trajectory (Stabilized)'); grid on;
legend('Position X', 'Position Y');
subplot(2,1,2);
if ~isempty(trigger_times)
stem(trigger_times, ones(size(trigger_times)), 'Marker', 'none');
end
title('Communication Events (Triggers) Over Time');
xlabel('Time (s)'); ylim([0 1.2]); grid on;