-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatlab_code.m
31 lines (30 loc) · 983 Bytes
/
matlab_code.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
a = arduino('com6', 'uno');
interval = 1;
x = 0;
y = 0;
t = zeros(1, interval);
napon = zeros(1, (interval));
t(1) = x;
napon(1) = y;
i = 0;
max = 3.75; %% the maximum possible voltage value allowed
while (x < interval) %% while loop is executed as long as the interval is greater than the variable on the x-axis
y = readVoltage(a, 'A0');
x = x + 1;
t(i+1) = x;
napon(i+1) = y;
i = i + 1;
if (y < max) %% if condition is fulfilled as long as the value of voltage (y axis) is less than the maximum
%% depending on what the measurement is for, you can change the condition
interval = interval + 1;
end
plot(x, y, 'r.');
axis([0, interval, 0, 10]);
xlabel('Vrijeme [sek]');
ylabel('Napon [V]');
grid on
hold on
tic;
pause(1); %% the pause time is the time for which the measurement is repeated
toc;
end