how do i find the Highest Point and area of each loop for the graph.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
N/A
el 22 de Oct. de 2019
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 comentarios
Adam Danz
el 22 de Oct. de 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?
Respuesta aceptada
Adam Danz
el 22 de Oct. de 2019
Editada: Adam Danz
el 23 de Oct. de 2019
General approach:
- Identify the starting point of each loop.
- Break apart the continuous data into individual loops.
- compute the vector length for each coordinate within each loop.
- Find the max vector length for each loop.
- 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))
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/244060/image.png)
4 comentarios
Adam Danz
el 23 de Oct. de 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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/244350/191023%20110042-Figure%202.png)
Más respuestas (0)
Ver también
Categorías
Más información sobre Title en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!