Azzera filtri
Azzera filtri

How to plot direction of forces on a body with polar plots or similar?

9 visualizzazioni (ultimi 30 giorni)
I'm simulating the forces acting on a stationary object. I have a data sample of a time series that includes Forces, and the direction where the object experiences the force (sample data set is attached).
subplot(2,1,1); grid minor; hold on
plot(data.time, data.force)
ylabel('[N]'); title('Force')
subplot(2,1,2); grid minor; hold on
plot(data.time, data.forceDirection)
ylabel('[deg]'); title('Force Direction')
Now, I want to visualize the force on a polar plot to see the direction in a rather graphical way. Something similar to the following figure (of course, the directions and values are different than the sample data attached).
I could be wrong to assume that this can be done, but if it is possible, how can I do this?

Risposta accettata

Star Strider
Star Strider il 10 Mar 2024
I can’t figure out what you’re plotting. The data are vectors, so any sort of surface plot isn’t possible, and I don’t understand the reason that the radius units in the surface plot image are in angular units. Does time enter into this?
% whos
t = data.time;
force = data.force;
direction = data.forceDirection;
polarplot(deg2rad(direction), force)
Ax = gca;
Ax.ThetaZeroLocation = 'top';
Ax.ThetaDir = 'clockwise';
When it is obvious what the data are, and if matrix data are available (or could be calculated from the existing vectors), then the sort of surface plot you want would be created by first calculating it as a matrix, using angle and radius units for the (x,y) data, then transforming that to polar (cylindrical) coordinates using pol2cart that will then plot it as Cartesian coordinates, however transformed into a polar coordinate surface. (Polar surface plot functions do not currently exist,m however they can be created easily enough using this approach.)
That would likely go something like this —
a = linspace(0, 2*pi*(1+1/250), 250);
r = linspace(0, 10, 100);
z = exp(-(r-5).^2 / 10);
[A,R] = ndgrid(a,r);
Z = repmat(z, numel(a), 1) .* (sin(a(:)+1));
surfc(A, R, Z, 'EdgeColor','none')
xlabel('a (rad)')
ylabel('r (unit)')
title('Original Matrix (angle and radius)')
[Xp,Yp,Zp] = pol2cart(A,R,Z);
surfc(Xp, Yp, Zp, 'EdgeColor','none')
title('Transformed To Cylindrical Coordinates')
Ax = gca;
% Ax.Visible = 'off';
surfc(Xp, Yp, Zp, 'EdgeColor','none')
Ax = gca;
Ax.Visible = 'off';
atix = linspace(0, 360, 13);
xv = 11*cosd(atix);
yv = 11*sind(atix);
text(xv(1:end-1), yv(1:end-1), compose('%5.0f°',atix(1:end-1)), 'Horiz','center', 'Vert','middle')
F = scatteredInterpolant(Xp(:), Yp(:), Zp(:));
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
rt = linspace(0, 10, 6).'; % Radius Tick Labels
rx = rt*cosd(15);
ry = rt*sind(15);
rtix = F(rx(:), ry(:));
text(rx, ry, rtix+0.5, compose('%g',rt), 'Horiz','center', 'Vert','middle')
title('Transformed To Cylindrical Coordinates With Added Tick Values For Angles & Radials (Top View)')
% hold on
% plot3(rx(:), ry(:), rtix, 'sk')
% hold off
This does not emulate the posted plot image, however it would likely be straightforward to adapt it to your data. Add a phase offset value to the angle calculations to change the location of the angle origin, and negate the angles to reverse their direction (anti-clockwise to clockwise).
  4 Commenti
Jake il 12 Mar 2024
@Star Strider I understand. This is a much better explaination than what I had in mind, and this will hopefully be enough for me to go forward.
I will accept this as the answer :) Thank you so much for the patience and the clear explaination.

Accedi per commentare.

Più risposte (0)


Scopri di più su Polar Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by