how to find difference between two points on graph in matlab

조회 수: 17 (최근 30일)
Muhammad Usman
Muhammad Usman 2014년 5월 21일
댓글: Star Strider 2014년 5월 24일
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

채택된 답변

Star Strider
Star Strider 2014년 5월 21일
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
Star Strider
Star Strider 2014년 5월 24일
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 2014년 5월 24일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Muhammad Usman
Muhammad Usman 2014년 5월 22일
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
Muhammad Usman
Muhammad Usman 2014년 5월 22일
but in this graph , it detect the bending at wrong point.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by