Warning: Matrix is singular to working precision. Help?

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개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by