- As a subscript by itself, such as A(5,:) meaning all columns of row 5 of matrix A; or
- in the form START:STOP or START:INCREMENT:STOP
On CodeHS I’m trying to solve 6.1.6, checkerboard, but I keep getting an error of an undefined variable on line 14, I wrote color_value = color_value + 1. Please help me
102 views (last 30 days)
Walter Roberson on 20 Nov 2022
There is no MATLAB function named def . You could define such a function and take advantage of command/function duality. For example, (see below for function definition)
However, there is no way to get past the problem in the next line
for i in range(4):
The : operator can only occur
In all cases, : followed by nothing else is a syntax error.
You cannot use the same technique as I showed for def in order to try to define for as a function that accepts character vectors, because for is a MATLAB keyword
That is, for is "magic" for MATLAB and cannot be overridden with a function or variable.
Therefore you will need to change your syntax, or else use a different function name instead of for in order to proceed in MATLAB.