How do I use arrayfun with inputs of arrays and scalar constants
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I want to pass in both arrays and constants into my arrayfun but the error says that all inputs have to be the same size, however when I looked at this simulation http://www.mathworks.com/help/distcomp/examples/using-gpu-arrayfun-for-monte-carlo-simulations.html it is evident that not all inputs are the same size. This is my code
k=1
while k<row*column
ref_mu_pixel=ref_mu(k)*ones(1,row*column);
new_mu(k)= arrayfun(@gpurunloop,ref_mu_pixel,...
ref_mu,smooth_parameter,targ_mu);
k=k+1
end
where ref_mu,ref_mu_pixel,and targ_mu are vectors and smooth_parameter is a scalar constant
Thank you
0 Commenti
Risposte (1)
Walter Roberson
il 22 Gen 2016
I suspect that an exception is made for the case of scalar inputs. You have inputs that are vectors that are not the same size as your data, perhaps.
1 Commento
Edric Ellis
il 22 Gen 2016
Modificato: Edric Ellis
il 22 Gen 2016
That's correct - the gpuArray version of arrayfun allows singleton dimension expansion. This is mentioned in the reference page:
"Nonsingleton dimensions of input arrays must match each other. In other words, the corresponding dimensions of arguments B, C, etc., must be equal to each other, or equal to one. Whenever a dimension of an input array is singleton (equal to 1), arrayfun uses singleton expansion to virtually replicate the array along that dimension to match the largest of the other arrays in that dimension. In the case where a dimension of an input array is singleton and the corresponding dimension in another argument array is zero, arrayfun virtually diminishes the singleton dimension to 0."
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!