how do i find the Highest Point and area of each loop for the graph.

1 view (last 30 days)
The excel file contains data set for a continous loop plotting the displacement against the load. 1. How do i find the highest point for each loop; 2. How do i find the area for each loop. The excel file is attached below.
  2 Comments
Adam Danz
Adam Danz on 22 Oct 2019
How do you define a loop? One possible definition could be that a new loop starts every time the line passed through the y axis below x=0.
When you say "highest point", do you mean the furthest point from (0,0) on each loop?
What are the units of the two columns of data? If the displacement is in radians (which appears to be the case, with a range of +/- 2pi), shouldn't the measurement be done in polar coordinates or shouldn't the data be converted to cartesian coordinates?
Lastly, (this one's important), what have you tried so far? How far are you in solving this?
N/A
N/A on 22 Oct 2019
A loop is as you have defined it (when the line passes through the y axis below x=0).
Yes I meant the farthest point from (0,0) on each loop.
Let's assume no units are involved and we are to work with what is currently on the excel file.
I am no where near solving this. This is a first project of this nature I am involved in.

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 22 Oct 2019
Edited: Adam Danz on 23 Oct 2019
General approach:
  1. Identify the starting point of each loop.
  2. Break apart the continuous data into individual loops.
  3. compute the vector length for each coordinate within each loop.
  4. Find the max vector length for each loop.
  5. plot results
The results are plotted in cartesian and polar coordinates for comparison. Black dots mark the largest vector for each loop. Note that both plots contains the exact same data.
See in-line comments for details
% dl is a 304 x 2 matrix of your [displacement, load] data
% Find where the displacement passes through the y axis below x=0
% This is where the x value passes from pos to neg while the y value is neg.
% note that this may get messy toward the center where x and y value are near
% (0,0) judgeing by the plotted raw data.
newLoopIdx = find([true;diff(dl(:,1)>=0)==-1] & dl(:,2)<=0);
% ^^^^ true because your data start at [0,0]
% Break your continuous data into loop segments
% 'loops' contains the [x,y] coordinates for each loop.
loops = arrayfun(@(i,j)dl(i:j-1,:),newLoopIdx(1:end-1),newLoopIdx(2:end),'UniformOutput',false);
% For each loop, compute max vector magnitude
% 'vecMags' contains the vector magnitude of each coordinate.
% Vector mag is the distance from (0,0)
vecMags = cellfun(@(s)hypot(s(:,1),s(:,2)),loops,'UniformOutput',false);
% find the max vector length and it's index for each loop
% maxVec is the max vector mag for each loop.
% maxIdx is the index value of the maxVec for each loop
[maxVec, maxIdx] = cellfun(@max, vecMags);
% Compute the area of the polygon created by each loop. To do this,
% we connect the two endpoints to form a complete polygon.
% loopArea is a vector of areas, one for each loop.
loopArea = cellfun(@(xy)polyarea(xy([1:end,1],1),xy([1:end,1],2)),loops);
% Plot results in cartesian coordinates
% Show each loop and mark the furthest point by a black dot
figure()
subplot(1,2,1)
hold on
grid on
cellfun(@(xy)plot(xy(:,1),xy(:,2),'-o'),loops) %show each loop
cellfun(@(xy,i)plot(xy(i,1),xy(i,2),'ko','MarkerFaceColor','k'),loops, num2cell(maxIdx))
% Plot in polar coordinates
subplot(1,2,2,polaraxes)
hold on
grid on
cellfun(@(xy)polarplot(xy(:,1),xy(:,2),'-o'),loops) %show each loop
cellfun(@(xy,i)polarplot(xy(i,1),xy(i,2),'ko','MarkerFaceColor','k'),loops, num2cell(maxIdx))
  4 Comments
N/A
N/A on 23 Oct 2019
Is there a way I can calculate the area above the x axis, area below the x axis , and then the absolute area under the curve.
Adam Danz
Adam Danz on 23 Oct 2019
@Taofeek Obafemi-Babatunde , instead of computing area relative to the x axis, I added a line of code to my answer that computes the area of the polygon formed by each loop. Since each loop is actually a disconnected spiral, I first connected the endpoints of each loop. This is the line in my answer that I added:
loopArea = cellfun(@(xy)polyarea(xy([1:end,1],1),xy([1:end,1],2)),loops);
To demonstrate, here is loop #12.
191023 110042-Figure 2.png

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!