find first value and repalce values following it

1 次查看(过去 30 天)
Good morning, I have an the following matrix 6*3:
1 1 1
1 1 1
0 1 1
1 1 0
1 1 1
0 0 1
I want to keep the first zero of each colomne and to replace the values that follow it by zeros to get:
1 1 1
1 1 1
0 1 1
0 1 0
0 1 0
0 0 0
Thank you for help bests

采纳的回答

Andrei Bobrov
Andrei Bobrov 2015-5-5
A = [1 1 1
1 1 1
0 1 1
1 1 0
1 1 1
0 0 1];
cumprod(A)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by