how do i combine figures' y - values

Hi, I have 57 graphs saved as figures. I want to combine all 57 graphs to make just one curve overall. I've tried copy and pasting the plots onto another graph but this just puts two functions on one graph. I've attached 3 of the graphs if someone would like to demonstrate how to do so.

回答 (2 件)

Image Analyst
Image Analyst 2015 年 11 月 22 日

0 投票

Save the data - the numbers - not the figures themselves. Then just have a program that read in all the data, say 57 .mat files or whatever, and plot them in one axes.

3 件のコメント

Ellis
Ellis 2015 年 11 月 22 日
Thanks Image Analysis, I'm struggling to do this, as I'm quite new to Matlab. Do you mind explaining in a bit more depth how to do this?
Image Analyst
Image Analyst 2015 年 11 月 22 日
Well you plotted something didn't you? Let's say you plotted y
plot(y, 'b-');
Now, instead of saving the whole figure with export_fig(gcf), just save the y values:
save('file 1', 'y');
Now just do that for all 57 different things you plot. Save to 57 different files, then recall them later with load().
Ellis
Ellis 2015 年 11 月 23 日
Hi Image Analysis I've tried done this but what next? I've saved them as such then loaded but I don't know what to do next.

サインインしてコメントする。

Thorsten
Thorsten 2015 年 11 月 23 日
編集済み: Thorsten 2015 年 11 月 23 日

0 投票

You just put it in a loop
ydata = zeros(1, 59991);
for i=1:57
open(sprintf('../../Downloads/figurefile%d.fig', i))
dataObjs = get(get(gcf, 'Children'), 'Children')
if i == 1, xdata = get(dataObjs(1), 'Xdata'); end
ydata = ydata + get(dataObjs(1), 'Ydata');
end
You see, fig files are not a good idea for data exchange. Use mat files instead. Ideally, store each ydata in a separate row of a single matrix 57x 59991 matrix P. Then just load P and use plot(sum, P).

1 件のコメント

Star Strider
Star Strider 2015 年 11 月 23 日
That code works for R2014a and previous releases, but not for R2014b and later releases.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

質問済み:

2015 年 11 月 22 日

コメント済み:

2015 年 11 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by