Stuart’s MATLAB Videos

Watch and Learn

Review of spiral puzzler

In the recent关于螺旋的益智, most of the code that was produced went along the following:
  1. Create the spiral matrix
  2. Find the indices of the ‘1’s in the binary targets matrix
  3. Find the values of the spiral matrix at the indices from step 2
  4. Choose the lowest value and corresponding indices from step 3
  5. 为Deltax和Deltay创建一个查找表
  6. Use the indices from step 4 in the look-up tables
  7. Deal with the edge case
Most of these steps have been taught in the abstract at some point in the movies from this blog. Let’s review the skills used in the above algorithm. The second movie below iscontent. 1.)Create the spiral matrixThis is just a matter of typing out the matrix. This is covered incidentally in many videos. 2.)Find the indices of the ‘1’s in the binary targets matrix3.)Find the values of the spiral matrix at the indices from step 2The video on Absolute and Logical indexing covers these two steps. The most relevant part starts at 3:50.

4.)Choose the lowest value and corresponding indices from step 3Min功能在这里运行良好。5.)为Deltax和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这在与步骤2. 7中的视频中涵盖。)Deal with the edge caseThis 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.

|

评论

To leave a comment, please click这里to sign in to your MathWorks Account or create a new one.