MATLAB Answers

Brett
0

How to draw an arrow or triangle

Asked by Brett
on 14 Nov 2012
Latest activity Edited by Image Analyst
on 9 Apr 2014

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

  0 Comments

Products

No products are associated with this question.

2 Answers

Answer by Image Analyst
on 14 Nov 2012

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 Comments

Brett
on 19 Nov 2012

Yes, as Walter said, this did not work.

annotation('arrow',x,y) doesn't work

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);

Answer by sina farahi
on 9 Apr 2014

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]);

  0 Comments


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!