matlab - Operation returns a scalar value when a vector of values is expected -
i'm evaluating simple function:
y = (2*x)/sqrt( 1 + x.^2 ); where x vector 100 values in it. however, matlab makes y equal single scalar value in instance. if do:
y = 2*x; i vector of values in y expected. if do:
y = x.^2; i also vector of values in y expected.
why above equation y = (2*x)/sqrt( 1 + x.^2 ); giving single value , not vector of values?
the operation b/a (given b = 2*x , a = sqrt(1+x.^2)) attempt perform matrix right division, row vector x solution in least squares sense system of equations ya = b, results in scalar value y.
for element-wise array division, perform operation b./a instead (note .).
Comments
Post a Comment