Error in my function

1 visualización (últimos 30 días)
Mark S
Mark S el 3 de Abr. de 2020
Comentada: Walter Roberson el 4 de Abr. de 2020
Hey, i wanna make a time vector of my data.
I have written this function:
function [ data_out_time ] = create_time( header_out , data_out_norm )
%% Create a time vector
% by reading the sampling interval of a measurement in the file
le= size(data_out_norm,1); % find out length of my cutted data matrix
% there may be a comma for decimal seperator
% -> search for it and replace it by a dot, otherwise the interval will be incorrect!
str_interval = strrep(header_out{1 , 1},',','.');
% convert sample time:
interval = str2double(str_interval); % from string to double
% Check if sample time is in range of t > 0
if interval<=0
error('incorrect sampling interval'); % Display error message in this case
end
%create output matrix
data_out_time = zeros(le,1); % prelocating matrix for performance
for r = 1:1:le % loop for generating time vector
data_out_time(r) = interval * (r-1); % time has to start at 0 -> *(r-1)
end
But i get everytime this error:
Brace indexing is not supported for variables of this type.
Error in create_time (line 9)
str_interval = strrep(header_out{1 , 1},',','.');
Where is the problem? My Data has the class "table"
  6 comentarios
Mark S
Mark S el 4 de Abr. de 2020
A friend has given the code to me. I'll ask my colleague
Walter Roberson
Walter Roberson el 4 de Abr. de 2020
If header_out were a table, then header_out{1,1} would be valid and would be the contents of the first row of the first column of the table
The code would also be valid if header_out were a cell array, or were a string array.
You would get that error message if header_out is character vector (including a file name), or numeric array, or is [] indicating empty.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Cell Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by