Data must be numeric, datetime, duration or an array convertible to double.
조회 수: 6 (최근 30일)
이전 댓글 표시
hello!
I have been asked to plot a graph of voltage against time in which the number of arguments are about 3460. Also the spreadsheet (.xlsx) has 8 columns, which I think may be creating problems. Given below is the code for the same.
T1 = readtable('D:\WARSAW UNIVERSITY OF TECHNOLOGY\SEMESTER 2\Sensors and Mesurement Systems (SMS)\turnX.xlsx','PreserveVariableNames',true);
TT1 = table2timetable(T1,'RowTimes',TimeX);
TimeX = (seconds(0.0):seconds(0.005):seconds(17.295));
x = TimeX
y = TT1;
plot(x,y)
댓글 수: 0
답변 (1개)
dpb
2019년 12월 8일
편집: dpb
2019년 12월 9일
TimeX isn't defined in the above code snippet before or by reading the table so that's an inconsistency that should be dealt with in specific code.
The error is from the line
x = TimeX
you can't (directly) turn a duration object/series into a double() array and, furthermore, in this case you don't need (nor want) to. As the error message goes on to say "To convert from durations to numeric, use the SECONDS, MINUTES, HOURS, DAYS, or YEARS functions." so there is a way if one really needs to do so, but that isn't the case here.
Use the timetable variable dot addressing; unfortunately, we don't know what the variable names are in the spreadsheet (or if there was a header row, even) so don't know what they are in the timetable.
The general syntax is:
plot(TT1.Time,TT1.Var1)
ADDENDUM:
Or, if you want to plot more of the variables, you can use the array indexing syntax for the dependent variables.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!