在图表中绘制值的行为

发布于 2024-11-03 09:37:00 字数 311 浏览 0 评论 0原文

我有一个具有以下格式的文件,其中包含一组浮点值:

a1 b1 c1
a2 b2 c2
---end-of-run-1
a1 b1 c1
a2 b2 c2
a3 b3 c3
a4 b4 c4
a5 b5 c5 
---end-of-run-2
...
...
...
till n runs

我想在图表上将这组列(即由 a、b、c 组成)显示为不同的曲线。此外,每次运行收集的值数量也会有所不同。

我可以在 matlab 中使用哪些内置函数来确定图中这组值(a、b、c)在某些 n 次运行 上的行为?

I have a file in the following format with a set of floating-point values:

a1 b1 c1
a2 b2 c2
---end-of-run-1
a1 b1 c1
a2 b2 c2
a3 b3 c3
a4 b4 c4
a5 b5 c5 
---end-of-run-2
...
...
...
till n runs

I want to show this set of columns (i.e. comprising of a,b,c) as different curves on a graph. Also, number of values collected for each run will vary.

Which in-built functions can I use in matlab to determine the behavior of this set of values(a, b, c) over some n runs in a graph?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放我走吧 2024-11-10 09:37:00

又快又脏,但我会逐行浏览文件。

function out = read_and_plot

fid = fopen('input.txt');

line_value = fgetl(fid);
i = 0;
while ischar(line_value)
     if strncmp('--end-of',line_value,8) % we need to start on the next run
        figure;
        plot_data = [col1' col2' col3'];
        plot(1:i', plot_data);
        legend('col1', 'col2', 'col3');
        % clear and restart
        i = 0;
        col1 = []; col2 = []; col3 = [];
     else % we have a line of data
        i = i + 1;
        data = sscanf(line_value, '%f %f %f');
        [col1(i),col2(i),col3(i)] = deal(data(1), data(2), data(3));
     end
     line_value = fgetl(fid);
end

fclose(fid);

return

现在,为了确定值的行为,这取决于您是否尝试曲线拟合或拟合分布,如果是这样,我会推荐曲线拟合工具箱。

Quick and dirty, but I would go line by line through the file.

function out = read_and_plot

fid = fopen('input.txt');

line_value = fgetl(fid);
i = 0;
while ischar(line_value)
     if strncmp('--end-of',line_value,8) % we need to start on the next run
        figure;
        plot_data = [col1' col2' col3'];
        plot(1:i', plot_data);
        legend('col1', 'col2', 'col3');
        % clear and restart
        i = 0;
        col1 = []; col2 = []; col3 = [];
     else % we have a line of data
        i = i + 1;
        data = sscanf(line_value, '%f %f %f');
        [col1(i),col2(i),col3(i)] = deal(data(1), data(2), data(3));
     end
     line_value = fgetl(fid);
end

fclose(fid);

return

Now, in order to determine the behavior of the values it would depend if you trying to curve fit or fit a distribution, if so I would recommend the curve fitting toolbox.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文