I need to create program which gives me 5 random numbers (from 0 to 9, integers). Then In second part I have to add at the end of those random numbers one negative in order from -1 to -5. And then send them via bluetooth to my arduino. I know how to solve the first step(5 random numbers) adn the last(write them via bluetooth). But for example when I have send these data 6 times. It has to look like this (negative numbers should go again from beginning).
7 8 1 8 6 -1
1 3 5 9 5 -2
5 6 7 1 2 -3
. -4
. -5
1 3 5 7 8 -1
Program which I use right now. clear all; clc;
b = Bluetooth('HC-05', 1);
fopen(b);
x = round(rand(1,5)*9);
a = num2str(x);
disp(x)
fwrite(b,a);
p = fscanf(b, '%s');
disp(p);
fclose(b);