MATLAB: Retrieve just the slope in polyfit

regression

I would like to return a vector containing just the slopes of various regressions so I can compare them. Right now I have a loop:
for i=1:n
slope{i}=polyfit(x,y(:,i),1)
end
However, this gives me a 1xn cell with each cell having a 1×2 double with slope AND intercept. I just want a nx1 vector containing the slopes. Any help would be greatly appreciated!

Best Answer

for i=1:n
slope{i}=polyfit(x,y(:,i),1)(1)
end
Related Question