getting wrong values when coding

1 view (last 30 days)
Guan-Yu
Guan-Yu on 2 Oct 2014
Answered: Mischa Kim on 2 Oct 2014
Hello,
There may be something wrong of my code that the outcome seems peculiar.
Here is my code.
>> [x,y]=meshgrid(0:0.02:1,0:1:0);
>> u=0*x;
>> v=4*(1*x-(x.^2));
>> quiver(x,y,u,v);
I just want to do vector analysis, and the outcome of v is the same as my expectation; that is,
v =
Columns 1 through 14
0 0.0784 0.1536 0.2256 0.2944 0.3600 0.4224 0.4816 0.5376 0.5904 0.6400 0.6864 0.7296 0.7696
Columns 15 through 28
0.8064 0.8400 0.8704 0.8976 0.9216 0.9424 0.9600 0.9744 0.9856 0.9936 0.9984 _1.0000_ 0.9984 0.9936
Columns 29 through 42
0.9856 0.9744 0.9600 0.9424 0.9216 0.8976 0.8704 0.8400 0.8064 0.7696 0.7296 0.6864 0.6400 0.5904
Columns 43 through 51
0.5376 0.4816 0.4224 0.3600 0.2944 0.2256 0.1536 0.0784 0
======================================================================================
The maximum of v is obviously one. But after graphing(quiver function), it doesn't equal to one. And I just want to know which part of my code is wrong.
Thanks.

Answers (1)

Mischa Kim
Mischa Kim on 2 Oct 2014
Guan-Yu, use instead
scale = 0;
quiver(x,y,u,v,scale)
This turns off the automatic scaling of the arrows.

Categories

Find more on Simulink 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!