전기 계량기용 작은 MATLAB 리포트예요. 하루에 CSV 하나, 열 = 계량기, 행 = 30분 간격이에요. Neovim 터미널에서 matlab -batch run_report로 실행해요. 재무팀에서 오늘 달라고 해서 기분이 별로예요.
2026-10-30은 interval이 3개고 숫자도 맞아요. 2026-10-31은 interval이 하나뿐이에요. 게이트웨이가 하루 대부분 죽어 있었거든요:
M101,M102,M103,M104
0.44,0.30,1.05,0.05
이날 총 kWh가 [0.44 0.74 1.79 1.84]로 찍혀요. 비용도 똑같이 틀리고, 왼쪽에서 오른쪽으로 갈수록 커져요. 합계는 행에 있는 숫자 네 개 그대로여야 해요. peak_kwh와 n_intervals는 맞아서 합계에서만 뭔가 이상해요.
function report = meter_report(deltas, cfg)
running = cumsum(deltas);
report.total_kwh = running(end, :);
report.cost = report.total_kwh * cfg.tariff;
report.peak_kwh = max(deltas, [], 1);
report.n_intervals = size(deltas, 1);
end
batches{k} = readmatrix(fullfile(dataDir, names{k}));
size(batches{k})가 1x4로 나오니까 파일은 제대로 읽힌 거예요. readmatrix가 헤더에 데이터 한 줄일 때 이상하게 동작하는 건가 싶기도 하고 (docs), 아니면 이 네이티브 Apple silicon 빌드가 다르게 동작하는 건가 싶어요. 아직 다른 머신에서는 아무도 돌려보지 않았어요. format long, MATLAB 재시작, 헤더 삭제도 해봤어요. 아무것도 안 바뀌었어요.
파일 정렬은 표준 라이브러리의 natsortfiles로 하니까 그건 문제가 아니에요.
왜 이날만 그럴까요? 코드도 같고 형식도 같은데요. 혹시 본 분 있나요?
영어에서 번역·원문 보기Small MATLAB report for electricity meters, one CSV per day, columns = meters, rows = 30 min intervals. Run it with matlab -batch run_report from Neovim terminal. Finance wants it today, so I am not in good mood.
2026-10-30 has 3 intervals and numbers are right. 2026-10-31 has only one interval, gateway was down most of the day:
M101,M102,M103,M104
0.44,0.30,1.05,0.05
Total kWh for this day prints [0.44 0.74 1.79 1.84]. Cost is wrong the same way, growing from left to right. Total should be just the four numbers from the row. peak_kwh and n_intervals are correct, so something is off only in totals.
function report = meter_report(deltas, cfg)
running = cumsum(deltas);
report.total_kwh = running(end, :);
report.cost = report.total_kwh * cfg.tariff;
report.peak_kwh = max(deltas, [], 1);
report.n_intervals = size(deltas, 1);
end
batches{k} = readmatrix(fullfile(dataDir, names{k}));
size(batches{k}) gives 1x4, so file is read fine. I suspect readmatrix does something strange with header plus one data line (docs), or this native Apple silicon build behaves differently. Nobody ran this on another machine yet. I tried format long, restarting MATLAB, deleting the header. Nothing changed.
Sorting of files is by natsortfiles from standard library, so that is not the problem.
Why only this day? Same code, same format. Anyone seen this?