user2604504
user2604504

Reputation: 717

Basic Matlab Syntax Understanding

I am learning Matlab and I see this line and I don't fully understand it. It's not something I can google so any help would be appreciated.

size(A([1:3,5:100],:))

Upvotes: 1

Views: 53

Answers (1)

Floris
Floris

Reputation: 46365

size(A([1:3,5:100],:))

Breaking into pieces (from inside out, not repeating things that were already explained):

[1:3,5:100]   - elements 1,2,3 and 5,6,7,…100 
A([], :)      - Rows 1,2,3 and 5,6,7,…10 , and all columns, of matrix A
size()        - the dimensions of the object

The result will be

[99 N]

Where N is the number of columns in A. Why 99? Because we only skip row 4 (and everything after 100). If A has fewer than 100 rows, this command will fail.

Upvotes: 3

Related Questions