directory - How to read this line in MATLAB? -


i came across following lines in matlab:

m = dir(fullfile(dataset,'*.png')); m = {m(~[m.isdir]).name}; 

i understand first line trying obtain .png files directory. but, second line trying perform? isdir seems determine input directory. that's new part. but, line trying perform?

thanks.

the second line getting files not directory , getting respective names , storing them cell array

  • m.isdir indicates if folder or not
    • returns 1 if is, 0 if not.
  • ~[m.isdir] indicate of values returned isdir 0.
  • m(~[m.isdir]) grabs objects in m determined logical indexing done above
  • m(~[m.isdir]).name gets names of of them
  • {m(~[m.isdir]).name} stores them in cell array

hopefully step step walkthrough helps.

while not sure why second line necessary because fullfile(dataset,'*.png') should return paths end in .png, not folder, guess check.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -