Рейтинг:  0 / 5

Звезда не активнаЗвезда не активнаЗвезда не активнаЗвезда не активнаЗвезда не активна
 

script
Fdisc = 16000;
fgen = Fdisc/24;
Q_graphs = 6;
ArrayLengthDevide = 40;
ArrayLength = 1024;
Offset = 255/2;
Amplithude = 255/2;

Phase = 0;

fileID = fopen('output.c','w');

i = 0;
for a = 1:Q_graphs
for i = 1:ArrayLength
y(a,i)= ceil(Amplithude*sin(fgen*Phase*2*pi/(Fdisc)) + Offset);
Phase = Phase + 1;
end
end

for a = 1:Q_graphs
fprintf(fileID, 'uint8_t buf%d[%d]={',a,ArrayLength);
for i=1:ArrayLength-1
fprintf(fileID, '%d,',y(a,i));
if rem(i,ArrayLengthDevide) == 0
fprintf(fileID, '\n');
end
end
fprintf(fileID, '%d',y(a,i+1));
fprintf(fileID, '};\n');
end

figure

for a = 1:Q_graphs
ax1 = subplot(Q_graphs,1,a);
plot(ax1,y(a,1:ArrayLength));
grid on;
end