why is my plot blank?
조회 수: 12 (최근 30일)
이전 댓글 표시
readtable ("LOGGER31.xlsx")
x = LOGGER31(:,"x_Datetime")
y = LOGGER31(:,"x_thermResistance")
plot (x,y)
댓글 수: 2
Stephen23
2023년 2월 19일
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.
답변 (2개)
Sulaymon Eshkabilov
2023년 2월 19일
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
Star Strider
2023년 2월 19일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

