Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Quiverplot of r hat / r squared in matlab

  1. Oct 26, 2014 #1
    Hi, I want to quiverplot this function in matlab.

    >> [X Y] = meshgrid(-2:.2:2,-2:.2:2);
    >> X1 = X./(X.^2+Y.^2).^1.5;
    >> Y1 = Y./(X.^2+Y./2).^1.5;
    >> quiver(X,Y,X1,Y1)

    I got this:


    What am I doing wrong?
  2. jcsd
  3. Oct 26, 2014 #2
    I think the problem is that for one X,Y pair, namely (X = -1, Y = -2), the resulting X1,Y1 pair turns out to be ( X1 = -0.89, Y1 = -inf ) and with one arrow being so huge, all the others become undetectable...I think you may be able to demonstrate this by making sure you do NOT plot the huge arrow...pick the limits of your graph to be, say, from 0 to 2...and I think you will start seeing what you expect.

    By the way, are the denominators supposed to be the same or not? the Y divided by 2 does not fit the pattern...from my ignorant point of view.
  4. Oct 27, 2014 #3
    Omg. Yes. I looked over it.For some reason I made the same Typing error over and over again.
    Y is wrong.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook