MATLAB Answers

where are my data?

3 views (last 30 days)
Paul Rogers
Paul Rogers on 14 Jan 2020
Commented: Star Strider on 14 Jan 2020
I plot a figure by using a function from a package.
Now I'd like to know the x and y values once I plot the curve.
Where are they stored

  0 Comments

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 14 Jan 2020
Try this:
F = openfig('untitled.fig');
ax = gca;
lines = findobj(ax, 'Type','Line');
for k = 1:numel(lines)
x{k,:} = lines(k).XData;
y{k,:} = lines(k).YData;
end
The x- and y-data for each line are in their appropriate cell arrays.

  4 Comments

Show 1 older comment
Star Strider
Star Strider on 14 Jan 2020
I am not certain what you intend withh ‘...plot but with a different x
Two possibilities:
F = openfig('Puntitled.fig');
ax = gca;
lines = findobj(ax, 'Type','Line');
for k = 1:numel(lines)
x{k,:} = lines(k).XData;
y{k,:} = lines(k).YData;
end
newx = -0.2:0.01:0.8;
for k = 1:numel(lines)
newy{k,:} = interp1(x{k}, y{k}, newx, 'linear','extrap'); % Interpolate-Extrapolate
end
or:
figure
plot(newx, cell2mat(newy)) % Plot Interpolated Values
grid
figure
plot(cell2mat(x).', cell2mat(y).') % Plot Previous Data With New X-Axis Ticks
xt = get(gca, 'XTick');
set(gca, 'Xtick',xt, 'XTickLabel',newx)
grid
One of these should do what you want.
Paul Rogers
Paul Rogers on 14 Jan 2020
for k = 1:numel(lines)
figure(4)
plot(FlowVector,y{k,:})
grid on
hold on
end
here's is the solution.
Man, thank you a lot, you really helped me.
I couldn't figured out without your help.
Star Strider
Star Strider on 14 Jan 2020
As always, my pleasure!
That’s what I’m here for!

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags

Products


Release

R2014b