- Here “x” is defined to be a row vector of size 1 x 51. So, the variable “f” inside the for loop evaluates to a vector of the same size as “x”. And each element of “y”, “y(i)” is a scalar which is assigned a vector inside the loop, thereby resulting in a dimension mismatch error.
- One possible solution may be to calculate the value of “f” for each index of “x”. This may be done by replacing “x” by “x(i)” in the expression for “f” as follows