MATLAB: How to change axis of graph and interpolate data

axisinterpolation

Sorry new to matlab if this seems like a basic question
Currently I have a plot that I have attached.I want to find the intersections between the plot and the line by interpolating the data. What functions/operations do i need to use on matlab
Thanks in advance

Best Answer

This works:
% GET INFORMATON FROM FIGURE:
openfig('Figure 3#.fig');
h1c = get(gca, 'Children');
Xdc = get(h1c, 'XData');
Xd = cell2mat(Xdc);
Ydc = get(h1c, 'YData');
Yd = cell2mat(Ydc);
% CALCULATIONS:
Ydn = diff(Yd, [], 1); % Subtract line from curve to create zero-crossings
Zx = circshift(Ydn, [0 1]) .* Ydn; % Use circshift to detect them
Zxi = find(Zx < 0); % Their indices
for k1 = 1:length(Zxi) % Use interp1(Y,X,0) to get line intercepts as Xzx
Xzx(k1) = interp1([Ydn(Zxi(k1)-1) Ydn(Zxi(k1))], [Xd(1,Zxi(k1)-1) Xd(1,Zxi(k1))], 0)
end
% PLOT ZERO-CROSSINGS ON FIGURE TO CHECK:
hold on
plot(Xzx, repmat(Yd(1,1),1,length(Xzx)), '*r')
hold off
The result:
Since you have the original data and don’t have to get it from the figure, you may want to change the variable designations from my Xd and Yd to yours. If you simply want the X-intercepts (my variable Xzx), then leave it as it is and use (or rename) Xzx as calculated here.