Avoid using for loop

1 visualizzazione (ultimi 30 giorni)
Zeynab Mousavikhamene
Zeynab Mousavikhamene il 8 Ott 2019
Risposto: Srivardhan Gadila il 11 Ott 2019
I am using this like which works fine:
Cellcount=Acc.perhexagon(Ac.time==data.timepoints(end).time);
I want to get information not only from the last timepoint. I want to have info from zeor timepoint to final time point with the step of 2. 0, 2, 4, 6, ...,end or something like this: 0:2:end
What would be the easiest way?
  6 Commenti
Alaster Meehan
Alaster Meehan il 8 Ott 2019
Tru using arrayfun.
Something like:
Cellcount = Acc.perhexagon( arrayfun(@(x) (x.time == Ac.time), data.timepoints(1:2:end)) );
Note, because you are indexing an array you will need to start from 1 not 0.
structfun might also work.
Cheers Alaster
Daniel M
Daniel M il 8 Ott 2019
Note that arrayfun is just a for loop internally.

Accedi per commentare.

Risposte (1)

Srivardhan Gadila
Srivardhan Gadila il 11 Ott 2019
You may refer to arrayfun, structfun & splitapply.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by