Warning: Matrix is singular to working precision. Help?
1 次查看(过去 30 天)
显示 更早的评论
Hi, Hoping somebody could help me with what is probably a very simple problem
When I'm running my code I'm getting the error: Warning: Matrix is singular to working precision.
The code is below:
clear all
clc
% x and y values
x = linspace(-2,2,50);
y = linspace(-1.5,1.5,50);
% Constants;
a = 0.5;
x0 = 1;
I = 1;
u0 = 8.85e-12;
% Making x and y grid;
[x y] = meshgrid(x,y);
% As there is a +/- in the equation for r have split them;
rplus = ((x+x0)^2 + y^2);
rminus = ((x-x0)^2 + y^2);
% For inside wire
% Having split r have had to split x component into plus and minus as well;
bixplus = ((u0*I*y)/(2*pi*rplus))+ ((u0*I*y)/(2*pi*(a^2)));
bixminus = ((u0*I*y)/(2*pi*rminus))+ ((u0*I*y)/(2*pi*(a^2)));
% Split y component into plus and minus as well;
biyplus = -((u0*I*(x+x0))/(2*pi*rplus))-((u0*I*(x-x0))/...
(2*pi*(a^2)));
biyminus = -((u0*I*(x-x0))/(2*pi*rminus))-((u0*I*(x+x0))/...
(2*pi*(a^2)));
% Plotting the points for wire at x+x0;
quiver(x,y,bixplus,biyplus)
Thanks, Chris.
0 个评论
采纳的回答
Brian B
2013-3-4
Do you want array division when you write
(u0*I*y)/(2*pi*rplus)
and similar expressions? If so, then you need to use
(u0*I*y)./(2*pi*rplus)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!