How to draw an arrow or triangle

Hello Matlab community, I am trying to draw an arrow. I am using Psychtoolbox and there doesn't seem to be a specific command for arrows or triangles. I know how to draw a line:
line = [X-3,Y-40,X+3,Y+40];
Screen('FillRect',window,[200,200,200], line');
So if someone knows the code to draw a triangle I can merge it with the code for a line to draw an arrow. Any help would be greatly appreciated.
Thanks, Brett

답변 (3개)

Sanjay Manohar
Sanjay Manohar 2017년 2월 14일

2 개 추천

This is not a MATLAB question. But for completeness, the answer should be
% create a triangle
head = [ 100, 100 ]; % coordinates of head
width = 10; % width of arrow head
points = [ head-[width,0] % left corner
head+[width,0] % right corner
head+[0,width] ]; % vertex
Screen('FillPoly', window,[200,200,200], points);
Image Analyst
Image Analyst 2012년 11월 14일

0 개 추천

Are you aware of the annotation() function?
annotation('line',x,y)
annotation('arrow',x,y)
annotation('doublearrow',x,y)
annotation('textarrow',x,y)
annotation('textbox',[x y w h])
annotation('ellipse',[x y w h])
annotation('rectangle',[x y w h])
annotation(figure_handle,...)

댓글 수: 4

Walter Roberson
Walter Roberson 2012년 11월 14일
This does not appear to be applicable to the drawing facilities supported by psychtoolbox.
Brett
Brett 2012년 11월 19일
Yes, as Walter said, this did not work.
sina farahi
sina farahi 2014년 4월 9일
annotation('arrow',x,y) doesn't work
Image Analyst
Image Analyst 2014년 4월 9일
편집: Image Analyst 2014년 4월 9일
At all? Or just with some figure created by the Psychtoolbox (which is not a Mathworks product and I don't have)? Does this draw an arrow for you:
plot(1:10, 'LineWidth', 2);
grid on;
annotation('arrow', [.21, .5], [.85, .5], 'LineWidth', 2);

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

sina farahi
sina farahi 2014년 4월 9일

0 개 추천

usage: Arrow(dot,vector); note: This function draw an arrow (head lines have pi/6 angle and the length of l/5) example: Arrow([10;11;12],[0.2;20;25]);

카테고리

질문:

2012년 11월 14일

답변:

2017년 2월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by