Help me with this error in the quiver function

1 view (last 30 days)
Hi,
I am fairly new to MATLAB, but not programming as a whole. I want to plot a vector from P = (1,3) to Q = (2,10), however when I do quiver(1,3,1,7), I get a vector with the end between y = 9 and 10 and x = 1.9. Can anyone tell me what the error is in my ways? I am using Matlab R2014a

Answers (1)

Star Strider
Star Strider on 31 Aug 2014
It’s necessary to do some ‘property diving’. Set the 'AutoScale' property to 'off':
c = [1 3; 2 10];
xy = c(1,:);
uv = diff(c,1);
figure(1)
quiver(xy(1), xy(2), uv(1), uv(2), 'AutoScale','off')
axis([0 5 0 12])
grid
This will give you the plot you want. You can find other options to experiment with in the documentation for Quivergroup Properties.

Categories

Find more on Vector Fields in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!