streamline line value v=atan(y/x) not giving me "Warning: Matrix is singular to working precision"
2 次查看(过去 30 天)
显示 更早的评论
>> [x,y]=meshgrid(0:0.1:5,0:0.1:5);
>> u=y;
>> v=atan(y/x);
Trying to do a streamline plot using the u and v listed above but I get the error "Warning: Matrix is singular to working precision." how am I able to plot it without that error?
0 个评论
采纳的回答
Steven Lord
2023-3-16
I'd recommend using atan2 instead of dividing. If you had to divide, use element-wise division (the ./ operator) instead of matrix division (the / operator.)
[x,y]=meshgrid(0:0.1:5,0:0.1:5);
u=y;
v1 = atan2(y, x);
v2 = atan(y./x);
The elements of v1 and v2 match except where v2 contains a NaN value (where both x and y are equal to 0.)
[v1(1), v2(1)]
v2(1) = 0;
isequal(v1, v2)
0 个评论
更多回答(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!