I have 2 sets of noisy data when plotted against each other forms a parallelogram . I want to simplify this to a simple parallelogram with 4 vertices and find the area within.
1 view (last 30 days)
Show older comments
[T1, UAPP] = textread('Uapp.txt', '%f %f'); %load data into arrays
[T2, UC] = textread('uc.txt', '%f %f');
C = 22*10.^-9;
F = 35*1000;
Q = C.*UC; % calculate Q
subplot(2,2,1); plot(UAPP, Q, 'R-'); title('Lissajous figure'); xlabel('UAPP'); ylabel('Charge (Q)');
max_UAPP = max(UAPP); %*efforts to find verticies*
max_Q = max(Q);
min_UAPP = min(UAPP);
min_Q = min(Q);
avg_UAPP = mean(UAPP);
avg_Q = mean(Q);
D = sqrt(((max_UAPP-avg_UAPP)^2)+((max_Q-avg_Q)^2));
pgon = polyshape([-8 -5 8 5], [-1 1 1 -1]);
subplot(2,2,2); plot(pgon);
POWER = S*F; %calculate power
I don't care much about plotting the parallelogram its just to help me visualise i tried to plot (pgon) with actual values from the graph but had many issues presumably because how small the values were, the current plot is a random unrelated test plot of a parralelogram. all i want to do is calulate the power, which is the area contained in the parralelogram by the frequency F. this should equal approximately 60 watts, any help is much appriciated, ive been stuck on this for over a week looking at different answers and trying various method before finally giving in and posting a question on it. Thank you.

0 Comments
Accepted Answer
Star Strider
on 11 Nov 2022
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1188663/Uapp.txt');
T2 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1188668/Uc.txt');
x = T1{:,2};
y = T2{:,2};
% figure
% plot(x, y)
[k,v] = boundary(x,y,0.5);
ps = polyshape(x(k), y(k));
pwr = polyarea(x(k),y(k)) % Calculate Power
[xc,yc] = centroid(ps);
figure
plot(x, y)
hold on
plot(xc, yc, 'p')
plot(x(k), y(k), 'r')
plot(ps)
hold off
grid
.
2 Comments
More Answers (1)
See Also
Categories
Find more on Surface and Mesh 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!