In MATLAB statements, there are four ways that = can be used:
- there can be a simple or indexed variable or list of simple or indexed variables in [], then a single = and then a function call or expression whose output is to be assigned to what occurs on the left
- There can be a statement that starts with for and then an un-indexed variable, and then a single = and then an expression; this creates a for loop
- Inside a () parameter list for a function call, there can be a simple unindexed variable name, then a single = and then a value; this is the same as using a name/value pair A=B being the same as "A", B
- You can have a pair of equal signs together, == to express a necessary logical relation
Your code uses a single = in the context of an if . That is not an assignment statement, not a for loop, and there is an indexed expression to the left of the = so this cannot be a shortcut for a name/value pair.
You should have used == to express the logical relation for the test.
However... you have the further problem that == is not defined between cell array elements. You can fix this in any of the following ways:
- if isequal(d(i,j), {'Failed'})
- if string(d(i,j)) == "Failed" %notice the double quotes
- if strcmp(d{i,j}, 'Failed')
- if d{i,j} == "Failed" %notice the double quotes