MATLAB: Regress(x,y) for least square regression of two variables x,y

regressionStatistics and Machine Learning Toolbox

when i use regress(x,y),I obtain only one answer :shouldn't i get two answers which are the slope and y-intercept ?

Best Answer

You don't show us your code, but I am guessing you neglected to add a column of ones to your x input, as described in the documentation:
doc regress
This code will give you the two-parameter output you expect:
x = [ones(3,1),rand(3,1)];
y = rand(3,1);
b = regress(y,x)