why is my plot blank?
2 views (last 30 days)
Show older comments
readtable ("LOGGER31.xlsx")
x = LOGGER31(:,"x_Datetime")
y = LOGGER31(:,"x_thermResistance")
plot (x,y)
2 Comments
Stephen23
on 19 Feb 2023
Maybe your data consists only of NaNs, or perhaps you are plotting only one point (which by default has no marker... no idea whay that is the default). In any case, without your data we cannot do much more than guess.
Answers (2)
Sulaymon Eshkabilov
on 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 Comments
Star Strider
on 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 Comments
See Also
Categories
Find more on Annotations 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!
