MATLAB Answers

How to read from Excel columns into Signal analyzer app?

8 ビュー (過去 30 日間)
farzad
farzad 2020 年 4 月 30 日
コメント済み: Peter Perkins 2020 年 5 月 5 日
Hi all
I read a two column signal ,time and displacement from Excel file and tried the Signal analyzer help page to convert it to something readable for the app. but
I was unsuccessfull in converting the Table time column into seconds.
str.st = mysig(:,1);
str.s1 = mysig(:,2);
T = struct2table(str);
T.st = seconds(T.st);
TT = table2timetable(T,'RowTimes','st');
Input data must be a real, numeric array.
I should mention that the structure contains two tables, and when I create T, I have a Table of tables and this might have caused the error.
it could have been much better that the signal analyzer app was able to internalize the data type conversion and adapt any parameter that was to be read.

  4 件のコメント

表示 1 件の古いコメント
farzad
farzad 2020 年 4 月 30 日
thank you , should I name all the columns ?
Error :
Row times must be specified as variable name or index, or as datetime or duration vector.
farzad
farzad 2020 年 4 月 30 日
and by the way, the error is in the previous line, you corrected the next line
T.st = seconds(T.st);
Sean de Wolski
Sean de Wolski 2020 年 4 月 30 日
What is T.st before the error?

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

採用された回答

Peter Perkins
Peter Perkins 2020 年 4 月 30 日
You must be leaving something out. If T.st is numeric, then T.st = seconds(T.st) creates a duration, and
TT = table2timetable(T,'RowTimes','st');
should be happy. So there must be something going on with
str.st = mysig(:,1);
str.s1 = mysig(:,2);
T = struct2table(str);
In any case, that seems round-about. I would think
T = array2table(mysig(:,1:2));
would do what you want, but even more directly
TT = timetable(seconds(mysig(:,1)),mysig(:,2))

  4 件のコメント

表示 1 件の古いコメント
farzad
farzad 2020 年 4 月 30 日
anyone there ??
Sean de Wolski
Sean de Wolski 2020 年 5 月 2 日
First column is an array of scalar tables... It is not time. You need to flatten the variables in the table.
Something like T = T{:,:}
How did you create this? Just call readtable or readtimetable directly on your Excel file...
Peter Perkins
Peter Perkins 2020 年 5 月 5 日
Yes, and in fact it looks like maybe your entire table is made up of cell arrays, each cell containing a 1x1 table? You have gone astray when reading from your Excel file; just use readtimetable or readtable.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by