- Where is the problem? My Data has the class "table"
Error in my function
1 view (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 4 Apr 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.
Answers (0)
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!