Warning: Matrix is singular to working precision. Help?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Brian B
el 4 de Mzo. de 2013
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!