how to find difference between two points on graph in matlab
17 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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
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
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!