| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
|
Today, my friend had a problem of rotating a figure 90 degrees clockwise for his paper. But he only had the MATLAB figure, the ".fig" file, and no data. The easy and elegant way to do it is to get the data points out of the figure and redrawing the figure. So here we go. In MATLAB, there are axes in a figure, and plot objects in an axis. In the plot object, you can find the data. We can do this using only the 'get' method. Suppose we have a figure like this, and want to restore data from the figure. subplot(2,1,1); plot(1:10, sin([1:10]/5)); First, we find the axes. >> axs = get(gcf, 'Children') That's right. The two strange numbers are the pointer to each axis. Let's try to see what objects are in the first axis. >> pos = get(axs(1), 'Children') So there's one plot object in the axis. Let's see what properties it has. >> get(pos)XData, YData, ZData are the data in the object. Yes, that's what we need! Let's make another plot with 90 degrees CW rotation. X = get(pos, 'XData'); Consult MATLAB documentation 'Handle Graphics' for details. |