Arturs Vancans
Arturs Vancans

Reputation: 4640

How to create a dataset in matlab with random values except for a specific area?

I have attached a sample image with explains the requirement.

I have a 16x16 matrix or random values (1-1000) generated by randi(1000, 16, 16)

Now I add a 4x4 matrix of same number (eg. 80) somewhere in the 16x16 matrix.

How to I make the large numbers (1-1000) to deviate to my new block of 80s so that the values near 4x4 bock have values closer to 80? enter image description here

PS. 500 near the small matrix should have been ~100 (my mistake)

Upvotes: 2

Views: 418

Answers (1)

Dennis Jaheruddin
Dennis Jaheruddin

Reputation: 21563

You can apply a weighted average.

  • Take a random number x and take 80.
  • If you are in the small matrix, the weight of 80 is 1 and the weight of x is 0.
  • The further you get from the small matrix, the smaller the weight of 80 and the larger the weight of x.

Upvotes: 1

Related Questions