how to find difference between two points on graph in matlab

24 views (last 30 days)
I have a graph of linear equation , the pattern of this equation is such that it has a bend in its graph, I want to find the change in the values( both along x-axis & y axis) at the start & end of this bend That graph is shown below. I want to find Δx along x axis & Δy along y axis( these are shown in color lines) , Kindly guide me how can i find that change in the matlab??
Thanks; Osman

Accepted Answer

Star Strider
Star Strider on 21 May 2014
Without access to your data I’m guessing here, but since the minimum of x and the minimum of y define the regions you’re interested in, I suggest:
ymin_idx = find(y == min(y))
xmin_idx = find(x == min(x))
delta_x = x(xmin_idx)-x(yminidx)
delta_y = y(xmin_idx)-x(yminidx)
I don’t have your data so I can’t test this code. You may want to reverse the signs of delta_x and delta_y since I don’t know how you want to calculate them.
  10 Comments
Star Strider
Star Strider on 24 May 2014
It took me a while to figure out your data.
This should work:
M = xlsread('New Microsoft Excel Worksheet.xlsx');
X = M(9:11, 1:2:end)
Y = M(9:11, 2:2:end)
for k1 = 1:size(M,2)/2
figure(k1)
plot(X(:,k1), Y(:,k1), '-')
hold on
plot(X(1,k1), Y(1,k1), 'pr', 'MarkerSize', 10, 'MarkerFaceColor','r')
plot(X(3,k1), Y(3,k1), 'pg', 'MarkerSize', 10, 'MarkerFaceColor','g')
hold off
grid on
end
Xmax = max(X(1:3,:),[],1);
Xmin = min(X(1:3,:),[],1);
DeltaX = Xmax-Xmin
Ymax = max(Y(1:3,:),[],1);
Ymin = min(Y(1:3,:),[],1);
DeltaY = Ymax-Ymin
The information you are interested in are all between indices 9:11, so I limited my analysis to those data. This should provide the analysis you want. I cannot say that it will be robust for all your data, but it works on those you provided.
Star Strider
Star Strider on 24 May 2014
As for plotting 324 plots, your system is probably running out of memory. Rather than have them all in memory at the same time, I suggest the savefig function. Note that ‘.fig’ files also contain all the data you used to plot them (they're actually very small MATLAB scripts). It is not difficult to recover those data from the ‘.fig’ files if you need to do that. I would create them and save them individually, labeling them appropriately so you know what they represent, then look at them individually (use the openfig function for that) or in small collections so that you do not exceed your computer’s memory capacity.

Sign in to comment.

More Answers (1)

Muhammad Usman
Muhammad Usman on 22 May 2014
This is the second graph, You can see that it has different bend from the above graph, I want such a program which run on the line of the graph & search the bend in line & and then at these points ( like A & B) , give me the difference of x-components of A & B along x axis( like 800-250=550) & give me the upper bend like point B , y- component along y- axis( around 1700)
  4 Comments

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots 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!