I know this is really basic, but I am new to MATLAB. After opening a .fig file, how do you actually work with the plotted data in the command window? All I see is the plot. I'm not sure how to actually get the data.
Type guide in command window. A new GUI dialog box will appear. In the dialog box you will select the existing GUI project. To to the tab and you will find the gui file which you want to edit.
Create a surface plot and make the figure invisible. Then, save the figure as a MATLAB figure file. Close the invisible figure. Open the saved figure and make it visible on the screen.
Actually, you don't even have to display the figure in order to get the data. FIG files are stored in the standard Matlab MAT format, that you can read using the built-in load() function. The figure handles and data are stored in a structure that you can easily understand and process.
Here's a really simple way:
Click on the object that you want to get the data from. There will be no indication that you have clicked on it.
>> xd = get(gco,'XData');
>> yd = get(gco,'YData');
Sometimes it can be hard to click on the line, or other object, itself. If you have this problem, click on the axes that contains the child(ren) you are interested in, then:
>> kids = get(gca,'Children');
This will give you an array of handles to the various children. You can try getting them one at a time by indexing into kids, or use the following to get all data at once. This will return the results as a cell array, which can be a little tricky if you haven't used them before:
>> xd = get(kids,'XData');
>> yd = get(kids,'YData');
>> xd1 = xd{1}; %# X Data from first line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With