kaylani - at which line are you observing this error? Note that when I run your code, the only problem I observe is with
and the error is
Unbalanced or unexpected parenthesis or bracket.
Once I correct this (remove the final comma), then I see how it is this same line, invoking bar, that generates your error message. Error using bar (line 58)
The length of X must match the number of rows of Y.
This is because your 'x' input, i (which should be renamed to avoid using MATLAB's representation for an imaginary number), is a 1x13 array whereas your 'y' input, P, is a 6x13 matrix. According to the documentation for bar
x values, specified as a vector or a matrix. If x and y are both vectors, then they must be equal length. If x and y are both matrices, then they must be equal size. If x is a vector and y is a matrix, then the length of x must equal the number of rows in y.
So your length for x must be 6 and not 13 if you wish it to work with the provided data. Or, perhaps you can transpose P as
Best Answer