Add a constant to just one column

52 views (last 30 days)
Dakota Bateman
Dakota Bateman on 13 Feb 2014
Edited: mohammed on 14 Feb 2014
I am trying to add 1900 to entries in my first column of a matrix to make them a more accurate date. 89 42 49 55 72 63 68 77 82 76 67 90 45 50 56 59 62 68 75 77 75 66 91 44 43 60 60 60 65 69 74 70 70.
I am reading in this matrix but want it changed to 1989 42 49 55 72 63 68 77 82 76 67 1990 45 50 56 59 62 68 75 77 75 66 1991 44 43 60 60 60 65 69 74 70 70
  2 Comments
mohammed
mohammed on 13 Feb 2014
Edited: mohammed on 14 Feb 2014
Dear Dakota Bateman
i haven`t understand your question completely but i think you want too add some constant value to first column of your matrix;
let
a = randi(5,5,5);
Result = [(a(:,1)+2),a(:,(2:end))]; % here i am adding 2 to my first column
i hope it will help you.

Sign in to comment.

Answers (1)

dpb
dpb on 14 Feb 2014
If your array/matrix is x
x(:,1)=x(:,1)+1900;

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!