File Exchange

## Plot 2D/3D Vector with Arrow

version 1.0.0.0 (775 Bytes) by
This function plots a line vector with arrow head.

Updated 20 Apr 2005

Arrowline 3-D vector plot.

vectarrow(p0,p1) plots a line vector with arrow pointing from point p0 to point p1. The function can plot both 2D and 3D vector with arrow depending on the dimension of the input

Example:
For 3D vector
p0 = [1 2 3];
p1 = [4 5 6];
vectarrow(p0,p1)

For 2D vector
p0 = [1 2];
p1 = [4 5];
vectarrow(p0,p1)

### Cite As

Rentian Xiong (2021). Plot 2D/3D Vector with Arrow (https://www.mathworks.com/matlabcentral/fileexchange/7470-plot-2d-3d-vector-with-arrow), MATLAB Central File Exchange. Retrieved .

Giuseppe Lastilla

winnie huang

Zamzam Alsulami

FANG GUAN

Alexander Romelfanger

SO many oversights. Arrow head is a different color from line, and it messes with your hold setting if you want more than one vector. Required modification to use at all.

Davide Magurno

Arturo Velasco

MA GP

phchang

Rolf Albert

destroys ny graph

Amir Pasha Zamani

It works well, but I need to control the colors, and I dont know how.

Carolyn Sullivan

Mikhail Akulov

Austin Sutton

Works as promised. If you want to plot multiple vectors, just use the vectarrow function multiple times while typing 'hold on' between each time the function is called.

Mojgan Dehghani

Undefined function or variable 'vectarrow'

Vikas Gupta

Michael Levy

This gets zero stars. you cannot plot more than a single vector on a plot.

Alina Alvarez

Hemanthakumar H N

I needed this kind of vector plot in my project. Thank you

Thuong Nguyen

Zhi Feng

Rafael Crefeld

Output: "Undefined function or variable"

Shaozheng Ji

MAURICIO MORENO LIMA

Diego Quiroga

useful :)

Justin Chu

Guillermo Berrios

Jianchao Li

Mark.

Ítalo Pedrosa

Expect the LineWidth options
Great Job

Chou

A great function!

icarli

wong

Ken

Pablo

Pratul

@ Neha Singhal:
Download the function file on top right corner and then run the code.

Neha Singhal

I tried used the function vectarrow as suggested here, but I am getting an error message saying:

??? Undefined function or method 'vectarrow' for input arguments of type 'double'.

Pls help....

Floris

Without shooting down your good intentions, I always use quiver3 and I'm satisfied with that.

-- Use quiver3 --

S

USE MATLAB'S BUILT IN "QUIVER" INSTEAD.

Gautam Sethi

This is life saver! I was looking for something simple like this; surprisingly, MATLAB doesn't have a built in function that does the job. Thank you for creating this function!

Cesar Chillon

Mehmet Ozerdem

p lks

thong kieu

yehua wei

very goog,thanks

d s

The matlab built in functions quiver / quiver3 achieve the same thing plus more, e.g. plotting multiple vectors

Cai Cai

Super! that is what i was searching for.

stef Keh

fgfg gdsfgdfg

LC Nguyen

Thank you very much for sharing

s p

Great!!

Dayu Lv

Great work, thanks

q q

Audrey Fan

:D you rock my world.

Mary Amon

I love you Rentian!!! Whoo!

Elane Phoenix

Superb. Exactly what I was looking for.

Cornelius Steinhardt

Asif Sheikh

sang jun

Levent K

thank you. It helps to me.

A A

Thanks a lot !!!!!!

Ronny Meza

Anhe Le

useless

Justin Maneely

did a kick ass job for plotting space cones for my orbital mechanics class

J. Willard Gibbs

Not very useful unless you can plot multiple vectors. The function does not cycle through plot colors, so each call plots the vector the same color, which gets hard to tell what is going on.

Easy fix-up: allow an optional color token in the pass variable list.

Charles Warren

2-d version works poorly when length of vector in x and y are much different, the arrowhead gets distorted.

Rentian Xiong

Oh, sorry for my ignorance. I did not search for those functions. I wrote this one simply because someone asked for help on matlab central.

Jérôme MyLastName

Waht is the difference between your file and those already posted in the File Exchange, especially arrow.m ?

##### MATLAB Release Compatibility
Created with R13
Compatible with any release
##### Platform Compatibility
Windows macOS Linux