Filter löschen
Filter löschen

Pass multiple images in cell array through cellfun

1 Ansicht (letzte 30 Tage)
Audrey
Audrey am 17 Jan. 2018
Beantwortet: Star Strider am 17 Jan. 2018
I'm trying to use a function that I wrote that takes the argument of an image file name:
function d = findDeflection(image);
I'd like to run this on multiple images. In a separate file, I call:
[filename,user_canceled] = imgetfile('MultiSelect',true)
and this returns a cell array - looks like:
{ {'filepath1'}, {'filepath2'},...}
I'd like to run each of these files through my findDeflection function, and have been trying to use cellfun like so:
[filename,user_canceled] = imgetfile('MultiSelect',true)
B = cellfun(findDeflection,filename);
but continue to get errors about not having enough arguments. Is there a special way to use cellfun if the function is one that I've created? Or maybe the problem is that the function needs to pass the filename cell as an argument and I'm not writing it correctly?

Akzeptierte Antwort

Star Strider
Star Strider am 17 Jan. 2018
Since ‘findDeflection’ has a formal funciton definition, you have to create a function handle to it with the ‘@’ sign.
See if this works in your code:
B = cellfun(@findDeflection,filename);

Weitere Antworten (1)

Audrey
Audrey am 17 Jan. 2018
Nevermind!
Looks like the correct syntax was:
B = cellfun(@findDeflection,filename);

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by