Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable subscript, as in t(rows,vars). To select variables, use t(:

30 views (last 30 days)
perc=0.8;
ecg_simulato=[];
for k=1:length(RRi_samples)
lungh_onda=round(perc*RRi_samples(k));
lungh_segmento=RRi_samples(k)- lungh_onda;%metto degli zeri fino al
%battito successivo
ecg_simulato=[ecg_simulato ecg(lungh_onda) zeros(1,lungh_segmento)];
Error using ese_process_ecg_2122_senza_grafico (line 30)
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable
subscript, as in t(rows,vars). To select variables, use t(:,i) or for one variable t.(i). To select rows, use t(i,:).
THIS IS THE ECG FUNCTION:
function x = ecg(L)
%ECG Electrocardiogram (ECG) signal generator.
% ECG(L) generates a piecewise linear ECG signal of length L.
% The ECG signal must be filtered (smoothed) with an N-point
% smoother e.g., Savitzky-Golay FIR filter.
%
% EXAMPLE:
% x = ecg(500).';
% y = sgolayfilt(x,0,3); % Typical values are: d=0 and F=3,5,9, etc.
% y5 = sgolayfilt(x,0,5);
% y15 = sgolayfilt(x,0,15);
% plot(1:length(x),[x y y5 y15]);
%
% See also SGOLAYFILT, ADAPTNCDEMO.
% Author(s): R. Losada
% Copyright 1988-2002 The MathWorks, Inc.
a0 = [0,1,40,1,0,-34,118,-99,0,2,21,2,0,0,0]; % Template
d0 = [0,27,59,91,131,141,163,185,195,275,307,339,357,390,440];
a = a0 / max(a0);
d = round(d0 * L / d0(15)); % Scale them to fit in length L
d(15)=L;
for i=1:14,
m = d(i) : d(i+1) - 1;
slope = (a(i+1) - a(i)) / (d(i+1) - d(i));
x(m+1) = a(i) + slope * (m - d(i));
end
% [EOF]

Answers (1)

Cris LaPierre
Cris LaPierre on 22 Feb 2022
When indexing a table, you need to specify row and variable (e.g. tblNm(row,'varNm')) or variable(row) (e.g. tblNm.varNm(row)). You can read more here.
For example
T = readtable('patients.xls');
T(5,8)
ans = table
Systolic ________ 122
T(5,'Systolic')
ans = table
Systolic ________ 122
T.Systolic(5)
ans = 122
% your error
T(5)
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable subscript, as in t(rows,vars). To select variables, use t(:,i) or for one variable t.(i). To select rows, use t(i,:).

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!