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

6 vues (au cours des 30 derniers jours)
Himalay Desai
Himalay Desai le 8 Déc 2019
Commenté : Himalay Desai le 29 Jan 2020
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)

Réponses (1)

dpb
dpb le 8 Déc 2019
Modifié(e) : dpb le 9 Déc 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.

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by