File Exchange

image thumbnail

polarG(start_comple​x,end_complex,arrow​_length,arrow_angle​,colour_code,line_w​idth)

version 6.0.0.0 (5.15 KB) by Scott Williams
Vector Diagram Matlab Plot

3 Downloads

Updated 01 Oct 2015

View License

Draws two dimensional vectors on Matlab figures. Uses complex numbers. Example provided. Should be used in conjunction with 'export_fig' for high quality output. For each vector, start point, end point, arrow head length, arrow tip angle, colour, & line width are specified. If pol2rec(magnitude, angle) also downloaded, can take vector start/end point in polar form.
How it works: arrow head is 250 carefully placed lines at right angle to vector, finishing at end point of vector.

Cite As

Scott Williams (2019). polarG(start_complex,end_complex,arrow_length,arrow_angle,colour_code,line_width) (https://www.mathworks.com/matlabcentral/fileexchange/53261-polarg-start_complex-end_complex-arrow_length-arrow_angle-colour_code-line_width), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)

Scott Williams Sorry, I understood.

I have two questions:
1 - When I need to build a vector with coordinates 3 + j * 0, there is the construction coordinate with 3 + j * 3?
2 - How can use the polarG another m - file?
Thank you!

Movenko: Walter Robinson suggests: "They tried to put that line at the top of the file and then run the result. They need to store the file unchanged and type that line at the command prompt." Is that what happened?

Using the example: polarG (0 + 0j, 2 + 1 * j, .1,30, 'r', 1) I have ::
  Error: File: polarG.m Line: 32 Column: 5
Function definitions are not permitted in this context.
What I have a problem?
Thank you!

Once downloaded, store in your default Matlab folder. In command window, type:
help polarG
For 'help' file. Final lines displayed can be copied and pasted to command prompt for an implemented example.

Please note that if you would like to add a legend at the command line, add 'fake' plots outside the range in line colour/format required, then make these plots invisible using axis([xmin xmax ymin ymax]) command. Legend command will not work as desired after using this command because polarG works by drawing thousands of lines as the arrowhead.

Updates

6.0.0.0

Changed description to indicate code fixed; there is no longer a problem with some arrows not looking right.

6.0.0.0

Previous version drew arrow for vector as horizontal or vertical lines. Now, arrow consists of series of lines at right angles to the vector. Additional argument required, angle of arrow (deg). Error handling arrow length > vector length

1.0.0.0

Added screenshot with output using export_fig. Other function here, pol2rec() is good to use in conjunction with this. In this way, polar form (magnitude and phase) of vector can be entered.

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: export_fig