我正在尝试从我的地热热泵日志文件中绘制值来分析它的性能。我尝试使用excel但是它很慢并且无法获得我想要的情节类型所以我正在尝试Octave。我完全没有八度音乐的经验所以请原谅我的无能!
我已经使用开放式办公室计算处理了.log文件,以获得合适的分隔格式。第一列是日期时间,格式为MM / DD / YY HH:MM:SS,总共有21列(但我只需要5列)和一个带标签的标题行,逗号分隔符是'。'和分隔符是','。该文件可以下载here,前7列如下所示:
02/19/2018 23:07:00,-0.7,47.5,42,47.3,52.1,1.5
我目前正试图用here的示范3剧情来描绘这个。第2,3,5和2列正确导入,因此我认为它是日期时间列1的问题。如何让Octave正确导入第1列并在此图中将其用作x轴?:
data=csvread('heatpump.csv');
clf;
hold on
t=data(:,1);
x=data(:,3);
y=data(:,5);
z=data(:,2);
o=data(:,8);
[hax, h1, h2] = plotyy (t, x, t, y);
[~, h3, h4] = plotyy (t, z, t, o);
set ([h3, h4], "linestyle", "--");
xlabel (hax(1), "Time");
title (hax(2), 'Heat pump analysis');
ylabel (hax(1), "Radiator and hot water temp");
ylabel (hax(2), "Outdoor temp and brine out");
答案 0 :(得分:2)
有许多方法。在这里,我将向您展示如何使用io包中的csv2cell
读取csv。我试图修改你现有的代码尽可能少。第一列是逐字使用的(好吧,我插入了一个换行符)。还有一个注释版本实际上进行了转换,然后您可以使用datetick
。顺便说一句,如果你添加谷歌驱动器链接,如果你添加直接链接,这将是很酷的,所以有人可以轻松抓住csv或在我已经完成的代码中插入网址,见下文。
set (0, "defaultlinelinewidth", 2);
url = "https://drive.google.com/uc?export=download&id=1K_czefz-Wz4HPdvc7YqIqIupPwMi8a7r";
fn = "heatpump.csv";
if (! exist (fn, "file"))
urlwrite (url, fn);
endif
pkg load io
d = csv2cell (fn);
# convert to serial date
# (but you don't have if you want to keep the old format)
#t = datenum (d(2:end,1), "mm/dd/yyyy HH:MM:SS");
data = cell2mat (d(2:end,2:end));
clf;
hold on
t = 1:rows (data);
# Attention: the date/time column time was removed above, so the indizes are shifted
x = data(:,2);
y = data(:,4);
z = data(:,1);
o = data(:,7);
[hax, h1, h2] = plotyy (t, x, t, y);
[hax2, h3, h4] = plotyy (t, z, t, o);
grid on
#set ([h3, h4], "linestyle", "--");
xlabel (hax(1), "Time");
title (hax(2), 'Heat pump analysis');
ylabel (hax(1), "Radiator and hot water temp");
ylabel (hax(2), "Outdoor temp and brine out");
# use date as xtick
# extract them
date_time = d (get(hax2(1), "xtick"), 1);
# break them after the date part
date_time = strrep (date_time, " ", "\n");
# feed them back
set (hax, "xticklabel", date_time)
set (hax2, "xticklabel", date_time)
print ("-S1200,1000", "-F:10", "out.png")