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.
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 .
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?
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?
Once downloaded, store in your default Matlab folder. In command window, type:
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.
Changed description to indicate code fixed; there is no longer a problem with some arrows not looking right.
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
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.
Inspired by: export_fig