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);
error in line 16 please help.

Answers (1)

I'm guessing you're trying to do something like this:
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 = zeros([2 12]); % preallocate the array
for i = 1:4
for j = 1:3
% don't overwrite the array every time
freqArray(:,j+(i-1)*3) = ([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);
plot(toneArray(:,i));
end

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!