Array indices must be positive integers or logical values.

symbol = {'1','2','3','4','5','6','7','8','9','*','0','#'};
lowFreqGroup = [697, 770, 852, 941]; %frequencies in rows
highFreqGroup = [1209, 1336, 1477]; %frequencies in columns
freqArray = [];
for i = 1:4
for j = 1:3
freqArray = ([lowFreqGroup(i); highFreqGroup(j)]); %create pairs
end
end
Fs = 8e3; %sampling frequency
N = 8e2; %tones of 100ms
t = (0:N-1)/Fs; %time
sine = 2*pi*t; %sine formula
toneArray = zeros(N, size(freqArray,2)); %array of N*12 for graph
for i = 1:12 %loop for each of 12 symbols
toneArray(:,i) =sum(sin(freqArray(:,i)*sine)); %make it sinusoidal
subplot(4,3,i);

Answers (1)

There were problems with indexing ‘freqArray’ and then ‘toneArray’.
See if this does what you want —
symbol = {'1','2','3','4','5','6','7','8','9','*','0','#'};
lowFreqGroup = [697, 770, 852, 941]; %frequencies in rows
highFreqGroup = [1209, 1336, 1477]; %frequencies in columns
freqArray = [];
for i = 1:4
for j = 1:3
freqArray(:,i,j) = ([lowFreqGroup(i); highFreqGroup(j)]); %create pairs
end
end
Fs = 8e3; %sampling frequency
N = 8e2; %tones of 100ms
t = (0:N-1)/Fs; %time
sine = 2*pi*t; %sine formula
toneArray = zeros(N, size(freqArray,2)); %array of N*12 for graph
for i = 1:12 %loop for each of 12 symbols
ii = ceil(i/3);
jj = ceil(i/4);
toneArray(:,i) =sum(sin(freqArray(:,ii,jj)*sine)); %make it sinusoidal
subplot(4,3,i)
plot(t, toneArray(:,i))
grid
title(sprintf('Symbol: %s',symbol{i}))
end
I will let you discover the changes I made to the code, and how they work.

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Asked:

on 27 Apr 2021

Commented:

on 28 Apr 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!