Invalid data argument error. Plotting date against MTD precipitation data but date format (dd-MM) is not able to be processed. How do I fix?

2 次查看(过去 30 天)
% DATA BEING USED IS INCLUDED FOR CONTEXT
clearvars
clear all
clc
% open data
dataMN=readtable('MNdatafix.csv');
dataTN=readtable('TNdatafix.csv');
dataLA=readtable('LAdatafix.csv');
% subplot 1
figure(1);
subplot(3,1,1);
plot(dataLA.DATE,dataLA.MTD_PRCP_NORMAL,'r-');
subplot(3,1,2);
plot(dataTN.DATE,dataTN.MTD_PRCP_NORMAL,'r-');
subplot(3,1,3);
plot(dataMN.DATE,dataMN.MTD_PRCP_NORMAL,'r-');

回答(1 个)

Seth Furman
Seth Furman 2022-12-7
Look's like you want "d-MMM" as your format instead of "dd-MM". See the following page for reference.
t = readtable("TNdatafix.csv",VariableNamingRule="preserve",TextType="string")
t = 320×7 table
STATION DATE DLY-PRCP-25PCTL DLY-TAVG-NORMAL DLY-TAVG-STDDEV MTD-PRCP-NORMAL YTD-PRCP-NORMAL _____________ ________ _______________ _______________ _______________ _______________ _______________ "USW00013893" "1-Jan" 0.05 42.7 10.6 0.16 0.16 "USW00013893" "2-Jan" 0.05 42.6 10.6 0.32 0.32 "USW00013893" "3-Jan" 0.05 42.5 10.7 0.48 0.48 "USW00013893" "4-Jan" 0.05 42.4 10.7 0.63 0.63 "USW00013893" "5-Jan" 0.05 42.3 10.7 0.79 0.79 "USW00013893" "6-Jan" 0.05 42.2 10.7 0.93 0.93 "USW00013893" "7-Jan" 0.05 42.1 10.7 1.08 1.08 "USW00013893" "8-Jan" 0.05 42 10.7 1.22 1.22 "USW00013893" "9-Jan" 0.05 42 10.7 1.36 1.36 "USW00013893" "10-Jan" 0.05 41.9 10.7 1.5 1.5 "USW00013893" "11-Jan" 0.05 41.8 10.7 1.64 1.64 "USW00013893" "12-Jan" 0.05 41.8 10.7 1.77 1.77 "USW00013893" "13-Jan" 0.05 41.7 10.7 1.9 1.9 "USW00013893" "14-Jan" 0.05 41.7 10.7 2.03 2.03 "USW00013893" "15-Jan" 0.05 41.7 10.6 2.15 2.15 "USW00013893" "16-Jan" 0.04 41.6 10.6 2.27 2.27
t.DATE = datetime(t.DATE,InputFormat="d-MMM")
t = 320×7 table
STATION DATE DLY-PRCP-25PCTL DLY-TAVG-NORMAL DLY-TAVG-STDDEV MTD-PRCP-NORMAL YTD-PRCP-NORMAL _____________ ___________ _______________ _______________ _______________ _______________ _______________ "USW00013893" 01-Jan-2022 0.05 42.7 10.6 0.16 0.16 "USW00013893" 02-Jan-2022 0.05 42.6 10.6 0.32 0.32 "USW00013893" 03-Jan-2022 0.05 42.5 10.7 0.48 0.48 "USW00013893" 04-Jan-2022 0.05 42.4 10.7 0.63 0.63 "USW00013893" 05-Jan-2022 0.05 42.3 10.7 0.79 0.79 "USW00013893" 06-Jan-2022 0.05 42.2 10.7 0.93 0.93 "USW00013893" 07-Jan-2022 0.05 42.1 10.7 1.08 1.08 "USW00013893" 08-Jan-2022 0.05 42 10.7 1.22 1.22 "USW00013893" 09-Jan-2022 0.05 42 10.7 1.36 1.36 "USW00013893" 10-Jan-2022 0.05 41.9 10.7 1.5 1.5 "USW00013893" 11-Jan-2022 0.05 41.8 10.7 1.64 1.64 "USW00013893" 12-Jan-2022 0.05 41.8 10.7 1.77 1.77 "USW00013893" 13-Jan-2022 0.05 41.7 10.7 1.9 1.9 "USW00013893" 14-Jan-2022 0.05 41.7 10.7 2.03 2.03 "USW00013893" 15-Jan-2022 0.05 41.7 10.6 2.15 2.15 "USW00013893" 16-Jan-2022 0.04 41.6 10.6 2.27 2.27

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by