using arrayfun for a function with multiple inputs
Mostra commenti meno recenti
I want to call my Before function with a 1 x 40 structure called struct for the s input, a value of 0 for the begins input, and a value of 20 for the ends input, but I can't figure out how to make it work with arrayfun correctly.
Here's what I have now, and the error that it gives me is at the bottom:
x = arrayfun(@Before, [struct,0,20]);
function v = Before(s,begins,ends)
Numbers = s.H;
firstColumn = Numbers(:,1);
rowsUnder = (firstColumn>begins)&(firstColumn<ends);
sNumNew = Numbers(rowsUnder,:);
v = mean(sNumNew(:,3));
end
Error using horzcat
The following error occurred
converting from double to
struct:
Error using struct
Conversion to struct from double
is not possible.
Error in ComparingMeans (line 22)
x = arrayfun(@Before,[struct,0,20]);
Risposta accettata
Più risposte (1)
Andrei Bobrov
il 26 Gen 2014
b1=0;
e1=20;
x = arrayfun(@(x1)Before(x1,b1,e1), your_structure)
2 Commenti
Michael
il 27 Gen 2014
Anik Hirenkumar Shah
il 27 Feb 2020
this worked for me as well. Thanks
Categorie
Scopri di più su Data Type Conversion in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!