Warning: Matrix is singular to working precision. Help?

3 ビュー (過去 30 日間)
Chris Corbett
Chris Corbett 2013 年 3 月 4 日
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.

採用された回答

Brian B
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 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by