How rotate a number as a vector in quiver plot?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all, I am having a strange issue with rotating vector along the circle that I cannot seem to debug - I am hoping fresh eyes will help. The problem is best described if I explain it as follows:
I have 16 vectors, and I wonder to set them along the circumferential of the circle radially; like they are passing from the centre of my circle,
clc; clear ;close;
%% Geometry of accelerometer positions (in cm) - edit r and/or n if required
r=9; % radius of nodes in cm
n=16; % number of (equally spaced) nodes around the half-circumference
theta=-pi:2*pi/(n-1):pi;
% angular position from 12 o'clock
x=2*r*sin(theta)'; y=-r*cos(theta)';
%% Type in modal matrix (i.e. mode shapes are columns)
% Dummy data for you to replace
w=[6,1.74;6.06,0.212;2.67,+3.24;1.42,1.43; 3.22,0.983;3.96,0.66;6.37,0.829; 6.64,2.55;8.4,3.27;...
6.07,1.74;6.06,0.212;2.67,3.24;1.42,1.43; 3.22,0.983;3.96,0.66;0.37,0.829];
% Type in the natural frequencies here
fn=[50,175];
%% Plot mode shapes as quiver plots - you should not need to edit this part
for ii=1:length(fn)
figure(ii)
quiver(x,y,x,w(:,ii))
hold on plot(x,y,'-r','Linewidth',3) % overlay geometry
title(['Mode shape of ', num2str(fn(ii)),' Hz mode'])
xlabel('x (cm)')
ylabel('y (cm)')
end
Respuestas (1)
Joe
el 13 de Ag. de 2015
If I understand what you're going for, make these changes:
- Fix your x and y definition
x = r*cos(theta)'; y= r*sin(theta)';
- Change the call to quiver so that you are plotting in the radial direction
quiver(x,y,w(:, ii).*x, w(:, ii).*y)
- Put your circle plot on a new line from "hold on"
hold on
plot(x,y,'-r','Linewidth',3) % overlay geometry
For me, this results in a plot with reasonable modeshapes, e.g.
Ver también
Categorías
Más información sobre Vector Fields en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!