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?

采纳的回答

Steven Lord
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)]
ans = 1×2
0 NaN
v2(1) = 0;
isequal(v1, v2)
ans = logical
1

更多回答(0 个)

类别

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

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by