How to draw a vector/line in a mesh
28 次查看(过去 30 天)
显示 更早的评论
Hi all,
I have the follwoing mesh:
%Defining space variables
L = 4; %boundary legth
ns = 25; %number of points on S axis
np = 25; %number of points on P axis
s = linspace(0,L,ns); %boundary variable
p = linspace(-1,1,np); % direction/angle variable
[S,P] = meshgrid(s,p); %construct coordinates meshgrid
% mesh needs X,Y and Z so create z
Z = zeros(size(S));
%Visualise the grid
figure;
mesh(S,P,Z,'Marker','o','MarkerFaceColor','k','EdgeColor',"k")
axis equal tight
view(2)
xlabel('$S$','Interpreter','latex')
ylabel('$P$','Interpreter','latex')
set(gca,'TickLabelInterpreter','latex')
set(gca,'FontSize',16)
And I want to draw a line/vector starting from the bottom of the mesh upwards in a way that it's inclined to the right with a certain angle. Could you please help on how to draw such a line in the mesh and how to calculate its angle with the norm (not with the x axis).
Thanks.
Lama
2 个评论
darova
2021-3-17
Can you make a simple drawing or something? Can you show how you want to draw a vector?
采纳的回答
darova
2021-3-18
Thanks for the drawing, i understand
Here is a way:
[x,y] = meshgrid([0 1]); % coordinates for square
t0 = 45;
[u0,v0] = pol2cart(t0,1); % angle and radius
surf(x,y,x*0,'facecolor','none')
quiver(0.5,0,u0,v0) % start position and components of vector
axis([-1 2 -1 2])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/554857/image.png)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!