My name is Hidde and i am working on a university project. I need to plot arrows inbetween serveral datapoints. I tried using the quiver function but the headwith gets
all weird. This is because my y axis runs from 0 to 500 and my x axis runs from 0 12. Does somebody know how to fix this? i want arrows with filled arrowheads that are all
the same size and shape regardless of arrow length ect.
i attached the relevant data and matlab files.

댓글 수: 6

Hidde Kemperink
Hidde Kemperink 2021년 1월 6일
편집: Hidde Kemperink 2021년 1월 6일
i have marked 2 example data points (1 and 2) in the end of the T_S_diagram code. the first flow should go from 1 to 2 to 3 to 4 and finnaly to 5
Adam Danz
Adam Danz 2021년 1월 6일
편집: Adam Danz 2021년 1월 6일
The term "quiver" isn't mentioned anywhere in either m-file. Where are you applying the quiver function?
Also, make it very easy for us to help you by reducing the amount of work we need to do to understand the problem. There are more than 3900 lines of code between your two m-files.
Hey adam, thanks for your reply. I tried using it between the first 2 datapoints i marked. But the arrow heads get scaled really weird so i removed it. This is due to the axis of my plot being so different
Hidde Kemperink
Hidde Kemperink 2021년 1월 6일
편집: Hidde Kemperink 2021년 1월 6일
The XSteam file is something provided by my university. It contains thermodynamic data i need and its not to be changed. Its just to run my diagram file
All i am trying to do is create a vector between 2 data points. But the axis are so different that the arrowhead scaling of quiver gets messed up
I see what you're describing. A much simpler way to demonstrate this is,
clf()
axes()
endPoint = [5.8, 175]; % [x,y] of arrow end point
headPoint = [7, 200]; % [x,y] of arrow head
plot([endPoint(1),headPoint(1)],[endPoint(2),headPoint(2)],'r*')
xlim([0,12])
ylim([0,500])
grid on
hold on
uv = headPoint - endPoint; % [x,y] distance
quiver(endPoint(1),endPoint(2),uv(1), uv(2),'b-','AutoScale','off')
This is a difficult problem because the quiver() function does not provide a way to change the arrow heads other than to turn them off. The annotation function with the arrow lineType is an alternative but problematic because it only receives corrdinates normalized to the figure (not the axes) so you'd need to compute the normalized position of the arrow and never change the axis limits or ratio.

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

 채택된 답변

Adam Danz
Adam Danz 2021년 1월 6일

0 개 추천

Given the problem described in my comment above, the easiest solution in my opinion is to replace the arrow with a different marker such as a circle and then define which end point of the vector the marker represents.
Here are two examples.
clf()
subplot(2,1,1)
endPoint = [5.8, 175]; % [x,y] of arrow end point
headPoint = [7, 200]; % [x,y] of arrow head
plot([endPoint(1),headPoint(1)],[endPoint(2),headPoint(2)],'r*')
xlim([0,12])
ylim([0,500])
grid on
hold on
uv = headPoint - endPoint; % [x,y] distance
quiver(endPoint(1),endPoint(2),uv(1), uv(2),'b-o','AutoScale','off','ShowArrowHead','off')
text(0,0,'o indicates base of vector in o---', 'VerticalAlignment','bottom')
subplot(2,1,2)
plot([endPoint(1),headPoint(1)],[endPoint(2),headPoint(2)],'r*')
xlim([0,12])
ylim([0,500])
grid on
hold on
uv = endPoint - headPoint; % [x,y] distance
quiver(headPoint(1),headPoint(2),uv(1), uv(2),'b-o','AutoScale','off','ShowArrowHead','off')
text(0,0,'o indicates head of vector in ---o', 'VerticalAlignment','bottom')

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Vector Fields에 대해 자세히 알아보기

제품

질문:

2021년 1월 6일

편집:

2021년 1월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by