I am unable to getting the arrows in the plot by using the quiver. Plot shows all the calculated data tip values but not showing the arrows.
Code as given below. Please help me for this problem.
[X,Y]=meshgrid(-2.5:0.1:2.5,-2.5:0.1:2.5);
Ur=(1+((Y-X)/2.5)-((X*Y)/(2.5^2)));
for i=1:size(X,1)
for j=1:size(X,2)
Uz1(i,j)=(3-(3.75/X(i,j)));
end
end
figure(1)
q=quiver(X,Y,Ur,Uz1,'ShowArrowHead','on','LineWidth',1,'MarkerSize',3);
q.Color = 'red';
q.AutoScaleFactor='1';

 채택된 답변

VBBV
VBBV 2022년 11월 8일
편집: VBBV 2022년 11월 8일
[X,Y]=meshgrid(linspace(-2.5,2.5,10));
Ur=1+((Y-X)/2.5)-((X.*Y)/2.5^2);
for i=1:size(X,1)
for j=1:size(X,1)
Uz1(i,j)=(3-(3.75/X(i,j)));
end
end
figure(1)
q=quiver(X,Y,Ur,Uz1,'LineWidth',1);
q.Color = 'red';
If you use autoscale factor along with arrowhead on it will distort the quiver diagram and misintrepret the plot.

댓글 수: 7

Thank you very much for answer and prompt reply.
VBBV
VBBV 2022년 11월 9일
편집: VBBV 2022년 11월 9일
The problem that quiver function may have is that when you specify an interval width(closely spaced)for an X or Y range , the resulting values produced by expressions for U or V may not appear due to grid mismatch and quiver plots are usually vectors with a specific direction. Its safer if you use default intervals produced by functions such as linspace or directly by a : operator available in Matlab.
If it solved your problem please accept the answer :)
Thank you sir for your responce. Similar problem is occuring when using closely spaced interval for meshgrid. I have one dought about, how to use the quiver function for different range for X and Y grid? as an example:
[X,Y]=meshgrid(-5:0.1:5,0:0.1:5);
[X,Y]=meshgrid(-5:0.1:5,0:0.1:5);
U = sin(Y);
V = cos(X); %e.g from doc ref page
quiver(X,Y,U,V)
Thank you sir.
VBBV
VBBV 2022년 11월 12일
편집: VBBV 2022년 11월 14일
If it solved your problem, pls accept the answer
Thank you for your humble responce. It has been solved my problem with your solution.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2022년 11월 8일

편집:

2022년 11월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by