I have a matrix with two columns, one of which is the date and another of which is a quantity that I have to perform some operations on. I wanted to add a third column to my existing matrix. I was going to go about this by formulating the third column as a column vector, and then adding it on to my existing matrix (although I am not sure how to add another column onto a matrix either- any help would be much appreciated!)
For my third column, I wanted to divide 399 by the (180,2) element in my existing matrix, and then each element in my new matrix would be formed by multiplying the value in the second column of the existing matrix by this quantity. My code was:
a3=([:,a(:,2).*399/a(180,2)])
and my existing matrix is
apre=dlmread('filename.csv',',',1,0);
a=[apre(1:180,:)]