gatorback
gatorback

Reputation: 1537

Struct one-liner

>> a=dir('*.slx')

a = 

4x1 struct array with fields:

    name
    date
    bytes
    isdir
    datenum

>> a(1).directory=pwd

a = 

4x1 struct array with fields:

    name
    date
    bytes
    isdir
    datenum
    directory

Is there a one-liner that can fill in the directory for array elements 2+? Seeking to avoid use of looping (for, while, etc.)

Upvotes: 1

Views: 72

Answers (1)

Cris Luengo
Cris Luengo

Reputation: 60444

You need the function deal:

[a.directory] = deal(pwd);

Upvotes: 6

Related Questions