How to write numbers before it occurs?
1 view (last 30 days)
Show older comments
Hey,
i have a problem that i am trying to solve for some time but still haven't. I have a matrix with 6 columns and a lot of rows. In example i put just 3 columns:
AA =
0.001 4.55 0
0.002 4.68 0
0.003 4.59 0
0,005 4.78 0
0,006 4.99 5
....
So what i need is to find the number (it can vary from 1 to 7) and take this number and write the same number up the cells until it reaches 3000 cell from that number. Than take another one and do the same and etc. So it this exaple i would get:
AA=
0.001 4.55 5
0.002 4.68 5
0.003 4.59 5
0,005 4.78 5
0,006 4.99 5
....
Could anyone lead me on the right track how to do it? I would appreciate any kind of help.
2 Comments
Accepted Answer
Walter Roberson
on 15 Oct 2019
rowidx = find(AAA(:,appropriate_column) ~= 0);
for start_row = rowidx(:).' %need to be sure it is a row vector
AA(startrow-3000:startrow-1, appropriate_column) = AAA(start_row, appropriate_column);
end
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!