Info

This question is closed. Reopen it to edit or answer.

Creating a parameter which indicates adding values to only part of the elements in a Matrix?

1 view (last 30 days)
alpha represents the proportion of elements in OldMatrix can be from 0 to 1.
How can I create a create a parameter like alpha that indicates that I only only want to add an integer like data to only a proportion of the elements in matrix such as OldMatrix ?

Answers (1)

Roger Stafford
Roger Stafford on 14 Apr 2017
p = 1:round(alpha*size(OldMatrix,1));
NewMatrix(p,:) = OldMatrix(p,:)+data;

This question is closed.

Community Treasure Hunt

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

Start Hunting!