Store plot values in a variable and then plot it
Show older comments
I am trying to save the values of the first figure in a variable and then plot it.
But as you can see my code doesn't plot the same thing in the first figure and in the second one.
I don't know if plotdata.XData(index) and plotdata.YData is what doesn't work or if it is the greiddedInterpolant.
M=200; %Slope of my lines
x=linspace(0,M,127);
y=linspace(0,1,127);
x1=linspace(M,255,127);
y1=linspace(1,0,127);
hold on
plotdata=plot(x,y)
plotdata1=plot(x1,y1);
hold off
[~, index] = sort(plotdata.XData);
F = griddedInterpolant(plotdata.XData(index), plotdata.YData(index));
[~, index] = sort(plotdata1.XData);
F1 = griddedInterpolant(plotdata1.XData(index), plotdata1.YData(index));
F2=[F.Values F1.Values];
figure
plot(F2)
Accepted Answer
More Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
