why is my plot blank?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
readtable ("LOGGER31.xlsx")
x = LOGGER31(:,"x_Datetime")
y = LOGGER31(:,"x_thermResistance")
plot (x,y)
2 Kommentare
Antworten (2)
Sulaymon Eshkabilov
am 19 Feb. 2023
It looks like that the whole imported data is not taken for x and y to plot them. See - e.g.:
D = readtable('DATA_A.csv');
x = D.N;
y = D.V;
plot(x, y, 'k-')
grid on
xlabel('N')
ylabel('V')
0 Kommentare
Star Strider
am 19 Feb. 2023
Try something like this —
LOGGER31 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1300315/LOGGER31.xlsx', 'VariableNamingRule','preserve')
x = LOGGER31.('%Datetime');
x{1} = string(datetime(x(1,1),'Format','yyyy/MM/dd HH:mm:ss')); % First Element Has A Different Format
x = datetime(string(x), 'InputFormat',"yyyy/MM/dd HH:mm:ss", 'Format','yyyy/MM/dd HH:mm:ss'); % Convert All To 'datetime'
LOGGER31.('%Datetime') = x % 'LOGGER31' With Consistent '%Datetime'
VN = LOGGER31.Properties.VariableNames;
x = LOGGER31.('%Datetime');
y = LOGGER31.('%thermResistance');
figure
plot (x,y)
grid
xlabel(VN{3})
ylabel(VN{4})
The plot was blank because the ‘%Datetime’ values were not converting correctly. The first element converted correctly, however the others were all NaT (‘not a time’), equivalent to NaN for numeric values, since they did not have the same formats as the first element, even though they were valid values, as my code demonstrates.
.
0 Kommentare
Siehe auch
Kategorien
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!