0

I have a problem in MATLAB. I have a NxM logical array called L but if I do dim(L) I get:

Undefined function or method 'dim' for input arguments of type 'logical'

size doesn't work either. length works but gives me only the number of columns and not the rows. The weird thing is that in the Matlab workspace it is correctly shown as an NxM logical array.

Does anyone know how I can get the amount of rows and columns of a logical array?

Thanks in advance.

1 Answer 1

2

If you want both the number of rows and colums, size is your best choice:

[nRows,nCols] = size(L)

If this fails, use clear size first, since you may accidentially have a variable of the same name in your workspace.

Sign up to request clarification or add additional context in comments.

3 Comments

Oh wow now I feel stupid. Indeed I had defined a variable called size :S Thanks a looot for the tip. Should I delete the post maybe? But seriously, why would MATLAB allow me to define a variable with a name of a built in function. At least a warning would be nice!
@Stefan: Matlab gives you a lot of freedom, including the freedom to shoot yourself in the foot. If you feel to embarrassed, you can delete your post, of course, otherwise, please accept my answer :)
@Stefan, I can't see any reason to delete this post. It might be helpful to many more people. I remember that I once defined a "try.m" script and tried to run it. I think it took me 2 hours to understand what is wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.