Can I extract XY data from a figure and sort it by the color of the datapoints?

1 回表示 (過去 30 日間)
Jacob Blumeier
Jacob Blumeier 2020 年 11 月 28 日
回答済み: Amrtanshu Raj 2020 年 12 月 1 日
I have a figure that is shown below, where the data is either red or blue. I need to extract the XY data from this figure and seperate the red data from the blue data. Is there a piece of MATLAB code that can extract just the data that corresponds to a certain property of the datapoints? While its hard to notice in the image, the circles representing the red data are also a different size from the blue data, so I could sort them by size too if it's easier.
  5 件のコメント
Jacob Blumeier
Jacob Blumeier 2020 年 11 月 28 日
It was an oversight on my part. The code I edited and used from my professor simulated particles in a rotatating fluid, and in his original simulation all of the particle locations were the same size. Because of that he just compiled all of the data into a text file. For my simulation I used particles of two different sizes and I kept it the same so that it goes to a text file, and all of the datapoints are jumbled together in that text file.
In short, I'm new to MATLAB and have no clue what I'm doing.
KSSV
KSSV 2020 年 11 月 28 日
You have to use some thing like this: https://in.mathworks.com/help/matlab/ref/allchild.html

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

回答 (1 件)

Amrtanshu Raj
Amrtanshu Raj 2020 年 12 月 1 日
Hi,
Since you have a .fig file, the following code will help you get back the datapoints. This is the basic structure, you may have to tweak it a little based on the original method used to plot it.
%lets say your figure is name fig2dataset.fig
fig = openfig('fig2dataset.fig'); %load the figure back to matlab
k = fig.Children.Children; %get the children of the figure file ie. the datapoints
for i = 1:size(k,1) %itterate to all the lines plotted
disp("Dataset"+i);
for j = 1:length(k(i).XData)
disp([k(i).XData(j) k(i).YData(j)])%disp the X and Y data points
end
end

カテゴリ

Help Center および File ExchangeDevelop uifigure-Based Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by