How implement sine wave on zeros array containing only 1 and 0
Ältere Kommentare anzeigen
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
Antworten (1)
Walter Roberson
am 14 Sep. 2022
0 Stimmen
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 Kommentare
Walter Roberson
am 14 Sep. 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
am 14 Sep. 2022
Instead of doing the calculations yourself I suggest using rescale() of the sine wave to the height of array
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!