Quiverplot of r hat / r squared in matlab

  • Context: MATLAB 
  • Thread starter Thread starter Waxterzz
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The discussion centers on generating a quiver plot in MATLAB using the meshgrid function. The user encountered an issue where one of the resulting vectors, specifically for the input (X = -1, Y = -2), resulted in an infinite value, causing the plot to display an undetectable number of arrows. The solution involves adjusting the plot limits to focus on a specific range, such as 0 to 2, to visualize the expected output. Additionally, there is a query regarding the consistency of denominators in the equations used for Y.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of vector fields and quiver plots
  • Knowledge of meshgrid function in MATLAB
  • Basic mathematical concepts related to functions and limits
NEXT STEPS
  • Explore MATLAB's quiver function documentation for advanced options
  • Learn about handling infinite values in MATLAB calculations
  • Research best practices for visualizing vector fields in MATLAB
  • Investigate the implications of using different denominators in mathematical functions
USEFUL FOR

MATLAB users, data visualizers, and anyone interested in creating and troubleshooting vector field plots in scientific computing.

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
4K
Replies
5
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
1
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K