MATLAB: How i extract the components of a vector/matrix output

regression linear

For example i have a function like a=polyfit(x,y,1) and the result is
a= 0.300 1.00
How can i extract a(1)=0.300 and a(2)=1.00?Thank you

Best Answer

Yes, that is the syntax. a(1) and a(2)
a=polyfit(x,y,1);
first_element = a(1);
second_element = a(2);