Data must be numeric, datetime, duration or an array convertible to double.
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
dpb
on 8 Dec 2019
Edited: dpb
on 9 Dec 2019
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!