Data must be numeric, datetime, duration or an array convertible to double.

9 visualizaciones (últimos 30 días)
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)

Respuestas (1)

dpb
dpb el 8 de Dic. de 2019
Editada: dpb el 9 de Dic. de 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.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by