I'm trying to apply a function to a vector where for each new row the same function applies but a variable changes. So for example if I have a vector with N
rows:
A = [1.2; 1.5; 1.8; 2.3; 2.7; 2.8; 2.9];
I want to subtract n*0.1
away from each row where n = row number
. So 1.5
in row 2 would be subtracted by 0.2 (2*0.1)
, 2.8
in row 6 would be subtracted by 0.6 (0.1*6)
, and so on.
To clarify I would like a function that says to my file, OK this is row n
and I want to subtract the number in row n
by n
multiplied by 0.1
. I would like the code to be able to read the file row by row so the end result is a vector that has done the above to each row. I think a loop would be needed?
I'm sure the solution is simple but I don't know how to do it.