Error in my function

1 回表示 (過去 30 日間)
Mark S
Mark S 2020 年 4 月 3 日
コメント済み: Walter Roberson 2020 年 4 月 4 日
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 件のコメント
Mark S
Mark S 2020 年 4 月 4 日
A friend has given the code to me. I'll ask my colleague
Walter Roberson
Walter Roberson 2020 年 4 月 4 日
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.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by