How implement sine wave on zeros array containing only 1 and 0
Mostrar comentarios más antiguos
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
el 14 de Sept. de 2022
0 votos
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
Walter Roberson
el 14 de Sept. de 2022
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.
Walter Roberson
el 14 de Sept. de 2022
Instead of doing the calculations yourself I suggest using rescale() of the sine wave to the height of array
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!