MATLAB Answers

# data extract from 3d line plot?

1 view (last 30 days)
Golak Mahanta on 28 Dec 2019
Answered: Image Analyst on 28 Dec 2019

#### 0 Comments

Sign in to comment.

### Answers (2)

Max Murphy on 28 Dec 2019
See example code and modify according to your data:
%% Make test data
fig = figure;
ax = axes(fig);
nPoint = 1001;
nSeries = 5;
k = ones(nSeries,1) * linspace(0,100,nPoint);
theta = randn(nSeries,1);
% Toy x-data
x = cos(k.*2*pi*0.1+2*pi.*theta).^(randi(4,5,1)).*(randn(nSeries,1) * 10);
% Toy y-data
y = randn(nSeries,nPoint) .* (randn(nSeries,1) * 10);
% Toy z-data
z = sin(k.*2*pi*0.1 + 2*pi.*theta).*(randn(nSeries,1) * 10);
% Labels
lab = cell(nSeries,1);
for i = 1:nSeries
lab{i} = sprintf('TestData %g',i);
end
% Plot them
plot3(ax,x.',y.',z.');
legend(lab);
%% Get 3D data
% Can use 'gca' here if don't have 'ax' handle
c = findobj(ax,'Type','line');
% c = findobj(gca,'Type','line'); % should work for your data
% This returns data in cell array, where each element matches
X = get(c,'XData'); % X{1,1} corresponds to Y{1,1} and Z{1,1}
Y = get(c,'YData'); % Y{2,1} corresponds to X{2,1} and Z{2,1} etc
Z = get(c,'ZData');

#### 0 Comments

Sign in to comment.

Image Analyst on 28 Dec 2019
If all you have is that one 2-D image, you can't. Exactly what data do you have? Are you the one who plotted it? If not, can you get it from them. Otherwise can you get the formulas that made those curves?

#### 0 Comments

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!