Review of spiral puzzler
In the recent Puzzler about the spiral, most of the code that was produced went along the following:
4.) Choose the lowest value and corresponding indices from step 3
The MIN function works well here.
5.) Create a look-up table for the deltaX and deltaY
This is a specialized matrix created most often with REPMAT. I cover how to make this look-up without REPMAT here along with other matrix creation skills in this new video.
6.) Use the indices from step 4 in the look-up tables
This is covered in the same video as step 2.
7.) Deal with the edge case
This is covered with an IF THEN statement. I made a video about SWITCH CASE statements that started out with IF THEN statements then converted them when it made better code.
- Create the spiral matrix
- Find the indices of the ‘1’s in the binary targets matrix
- Find the values of the spiral matrix at the indices from step 2
- Choose the lowest value and corresponding indices from step 3
- Create a look-up table for the deltaX and deltaY
- Use the indices from step 4 in the look-up tables
- Deal with the edge case
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.