Possible to find if a portion of an array equals an array of the same size as the portion?
Show older comments
I have a school project where I have written a program that creates a simple binary array based on inputs. The output array usually looks something like this:
X = [1 0 0 0 0 1 0 1 0]
I need to write a simple script that will convert this to material type, for which I have the key. Basically, if the last 3 elements of the array ([0 1 0]) equal to [0 1 0], then my material is Red Glass. They could potentially equal 3 other possibilities. If the array elements 2 through 6 ([0 0 0 0 1]) equal [0 0 0 0 1], then my material is type 1 zero and type 2 zero. There are potentially 15 other possibilities of what these specific elements might be. The first element of the array is always 1, and does not matter.
I basically need to write a script that is an IF function that asks if the last 3 elements of the array equal this, this, or that, then I have THIS (and so on), and then do the same thing for elements 2-6, and then pair up the conclusions.
Accepted Answer
More Answers (0)
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!