Streamslice in polar coordinates problem

10 次查看(过去 30 天)
Hey,
I'm struggling with my code, which should create streamlines of vector field in polar coordinates. I have converted (r, phi) components to normal cartesian coordinates (x,y). Components in terms of (r, phi) were distributed uniformly, it means for r = 0:const:10, phi = 0:const:2*pi. Now I'm trying to compute the streamlines of this vector field using streamslice(x,y,wx,wy), but I get an error:
streamslice(x,y,Gradx,Grady)
Error using griddedInterpolant
Interpolation requires at least two sample points in each
dimension.
Error in interp1 (line 151)
F = griddedInterpolant(X,V,method);
Error in stream2 (line 62)
sxi=interp1(xx(:),1:szu(2),sx(k));
Error in streamslice>nicestreams (line 313)
vertsf = stream2(x,y, u,
v,xstart,ystart,streamoptions);
Error in streamslice (line 138)
[vertsout, avertsout] =
nicestreams(x,y,u,v,density,arrows);
To be detailed, each matrix inside the streamline funtion has dimensions of 201x73.
I also tried to compute a little bit different streamslice:
streamslice(x',y',Gradx',Grady')
which sometimes worked for other people (yes, I've done my "research")... but it gives the same error message.
I also enclose quiver plot of this vector field if it could help someone. If someone helped mi with this problem I would be really grateful. Really, I don't have any idea.
vectorfield.png

回答(1 个)

Saurabh
Saurabh 2024-11-19
For the 'streamline' function to work correctly, the 'x' and 'y' inputs must form a grid of coordinates that specifies the location of each '(u, v)' vector component. However, if the user provides disorganized matrices for 'x' and 'y' that don't form a proper grid and contain duplicate values, it can lead to issues.
The grid values for 'x' and 'y' don't need to be uniformly spaced, but they must be monotonic. This means they should either increase or decrease consistently along one dimension while remaining constant along the other, similar to the requirements for 'contour()' function inputs. The 'meshgrid()' function can be useful for generating these matrices correctly.
The same information can be found here:
I hope this helps.

类别

Help CenterFile Exchange 中查找有关 Vector Fields 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by