MATLAB Quiverplot of r hat / r squared in matlab

  • Thread starter Thread starter Waxterzz
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
The discussion revolves around creating a quiver plot in MATLAB using a specific function. The user encounters an issue where one of the resulting vectors, specifically for the coordinates (X = -1, Y = -2), produces an infinite value for Y1, causing one arrow to dominate the plot and render others undetectable. It is suggested to adjust the graph limits to visualize the expected results better. Additionally, there is confusion regarding the denominators in the equations used for X1 and Y1, particularly the division of Y by 2, which seems inconsistent. Ultimately, the user acknowledges a repeated typing error in the Y variable as the source of the problem.
Waxterzz
Messages
82
Reaction score
0
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:

MwQ72tw.jpg


What am I doing wrong?
 
Physics news on Phys.org
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.
 
gsal said:
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.

Omg. Yes. I looked over it.For some reason I made the same Typing error over and over again.
Y is wrong.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
Replies
5
Views
3K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K