Dear Researchers,

I need to convert the following equation in R from Matlab

a = [x y ones(size(x))];
b = [-(x.^2+y.^2)];
a\b

ans =

   -9.9981
  -16.4966
   -7.6646

my solution in R is:

a = cbind(x,y,rep(1,length(x)))
b = cbind(-(x^2+y^2))

> head(a)
            x        y
[1,] 14.45319 5.065726 1
[2,] 14.99478 5.173893 1
[3,] 14.64158 5.616916 1
[4,] 14.61803 6.624069 1
[5,] 14.19997 6.794587 1
[6,] 15.08174 8.224843 1
> head(b)
          [,1]
[1,] -234.5564
[2,] -251.6125
[3,] -245.9255
[4,] -257.5652
[5,] -247.8057
[6,] -295.1068

following MATLAB/ R Reference
http://cran.r-project.org/doc/contrib/Hiebeler-matlabR.pdf
the a\b could be converted by solve(a,b) but i get the following error:

> solve(a,b)
Error in solve.default(a, b) : 'b' must be compatible with 'a'

thanks for any help
Gianni

	[[alternative HTML version deleted]]

