![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/237749/image.png)
How to plot circle with direction?
9 次查看(过去 30 天)
显示 更早的评论
I wish to plot a circle with direction of its motion.An exmaple is attached below.![Path_Ideal.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/237730/Path_Ideal.jpeg)
![Path_Ideal.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/237730/Path_Ideal.jpeg)
I wish to get around 5-10 arrows per circle (that can be chnaged as per our need).
Below attached matlab.mat file is the data file.
The code goes like:
subplot(2,2,[1 3])
h1 = plot(x, y, '-','Color','b','LineWidth',2);
Now I dont know how to put 5-10 arrows showing direction.
Can anyone help?
0 个评论
回答(1 个)
Bruno Luong
2019-9-10
编辑:Bruno Luong
2019-9-10
2D version. adapt to your need
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/237749/image.png)
% circle parameter
r = 5;
cx = 0;
cy = 0;
cfun = @(tt) [cx+r*cos(tt); cy+r*sin(tt)];
xy = cfun(linspace(0,2*pi,361));
close all
hold on
plot(xy(1,:),xy(2,:),'b');
% arrows parameters
m = 10; % number of arrows
h = 0.1*r; % height
w = 0.1*r; % width
dir = -1; % 1 anticlock, -1 clock
a = [-w/2 0 w/2;
-dir*h 0 -dir*h];
for k=1:m
tt = 2*pi*k/m;
R = [cos(tt) -sin(tt);
sin(tt) cos(tt)];
xy = cfun(tt)+ R*a;
plot(xy(1,:),xy(2,:),'b');
end
axis equal
5 个评论
michael
2021-1-20
I'w suggest to set
X = 10; % this is step size - each 10th point will have a vector
vSelect0 = 1:X:(lenTime-1);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Thermal Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!