Question

Understanding parameters sent to Matlab quiver function

From the documentation, I saw that Color parameter can be passed to the quiver function as either

'Color', 'k'

or just

'k'

If came across some alternate calls to the quiver function:

quiver(longitude, latitude, u, v, 'Color', 'k');
quiver(longitude, latitude, u, v, 0.5, 'k');
quiver(longitude, latitude, u, v, 0, 'k');

From the documentation, I understood parameters till u,v. After running the code, I see that call with 0.5 as parameter results in arrows that are bit more dispersed than first call. Call with 0 as parameter results in just dots (no arrows).

Can someone please explain how the 0 or 0.5 params are being interpreted by the quiver function?

 2  19  2
1 Jan 1970

Solution

 1

MATLAB documentation typically shows the different ways of calling functions, and explicitly explains each input. In your example you are using two different ways of calling quiver per the documentation:

https://uk.mathworks.com/help/matlab/ref/quiver.html

All options (as of 24a)

quiver(X,Y,U,V)
quiver(U,V)
quiver(___,scale)
quiver(___,LineSpec)
quiver(___,LineSpec,'filled')
quiver(___,Name,Value)

Where ___ means you can use any of the previous syntaxes, plus the input being described. So you are specifically asking about the two variants

  1. quiver(X,Y,U,V,scale,LineSpec), where scale is 0 or 0.5, and LineSpec is 'k' (a black line). The scale and line spec options have their own detailed docs on the same page

    e.g. your quiver(longitude, latitude, u, v, 0.5, 'k');

https://uk.mathworks.com/help/matlab/ref/quiver.html#mw_fe38877d-5343-48ab-aa8f-87ffbcb85fe4 scale - Arrow scaling factor, specified as a nonnegative number or 'off' [...]

https://uk.mathworks.com/help/matlab/ref/quiver.html#mw_b668e255-e1d3-40c8-a5cd-e426dd74c0ff LineSpec - Line style, marker, and color, specified as a character vector or string containing symbols [...]

  1. quiver(X,Y,U,V,Name,Value) where you're providing one name-value pair which is the color

    e.g. your quiver(longitude, latitude, u, v, 'Color', 'k');

https://uk.mathworks.com/help/matlab/ref/quiver.html#namevaluepairarguments

[...] Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'Color','r','LineWidth',1 [...]

2024-07-19
Wolfie