简体   繁体   中英

MATLAB : cellfun and two variables function

temptemp is 1 X 44 cell : every cell is 1 X 3130 array double.

tempwmul is 1 X 44 cell : every cell is 1 X 1 trained network.

I want to simulate every network with the relative array double :

for ilog=1:44

tempoutemp{ilog} = sim(tempwmul{ilog},temptemp{ilog}); 

end

in vectorized mode using cellfun :

tempoutemp=cellfun(@sim,tempwmul,temptemp,'UniformOutput', false);

The code doesn't return errors but in vectorized mode it uses always the first network for all array data and result is obviously different...some help?

As Sardar Usama said: cellfun is not a vectorised mode, as far as I know.

Anyhow, if you truly fancy to use the functional style (for style's reasons, not for performance), I guess you could do:

tempoutemp = arrayfun (@(idx) sim(tempwmul{idx}, temptemp{idx}), 1 : length(temptemp), 'Uni', 0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM