%% Hello World example
lastSeq   = 15;
thisTimer = timer;
thisTimer.Period         = 1/2;
thisTimer.TasksToExecute = 15;
thisTimer.ExecutionMode  = 'fixedRate';
thisTimer.TimerFcn       = @timer_update;
start(thisTimer);

function timer_update(myTimer, ~)
fprintf(1, '%02d | Hello world!\n', myTimer.TasksExecuted);
end

%% bubble sort algorithm
clear; close all; clc
N = 30;
R = 10*rand(1, N);
for startMove = 1:N-1
    for pos = 1:N-startMove
        if R(pos) > R(pos+1)
            R([pos, pos+1]) = R([pos+1, pos]);
        end
        figure(1);
        plot(R,'*','LineWidth',2);
        pause(0.01);
    end
end
issorted(R)

%% Sorting a vector
>> v  = reshape(magic(4)', [1 numel(magic(4))])
>> v  = sort(v, 'descend');
>> v1 = mod(v, 3) == 0 & v > 10
>> v(v1)
>> find(v1)

%% Decrypting a message
chars = 'acdgmrs'; volts = 1:7;
message = blanks(length(samples));
for iVolt = volts
   logCondition = samples > (iVolt - 0.5) & ...
      samples < (iVolt + 0.5);
   indices = find(logCondition);
   message(indices) = chars(iVolt);
end
disp(message)

%% Measured data
data = accumarray(TimeAndPlace, MeasuredData, [], @mean);
dataA = data(:,1); dataB = data(:,2); dataC = data(:,3);