Streamslice in polar coordinates problem
8 次查看(过去 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.
0 个评论
回答(1 个)
Saurabh
2024-11-19,3:52
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!