How implement sine wave on zeros array containing only 1 and 0

Hello, I want yo create an array like below containing 1's and 0's. The 1's are for sine wave points. Can anybody help me how can I get this type of array:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0
0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0
1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0

Respuestas (1)

Walter Roberson
Walter Roberson el 14 de Sept. de 2022
If you use the Computer Vision Toolbox then you can insertShape into an array. That returns an rgb array so you would binarize it afterwards.

2 comentarios

Alternatively, take your sine wave and multiply it by half the height of your array and add half the height and add 1. Round to integer. Now use subs2ind with size of your array, and 1:width as the third parameter, and the calculated values as the second parameter, which will give you linear indices. Set those locations to 1.
Instead of doing the calculations yourself I suggest using rescale() of the sine wave to the height of array

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Productos

Versión

R2022a

Etiquetas

Preguntada:

el 14 de Sept. de 2022

Comentada:

el 14 de Sept. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by