Error with cellfun using
Afficher commentaires plus anciens
I have a large code and I'm stuck on using cell arrays. I have some x values in cell array and i want to assign them with a function. There is a loop, function is working correct in first loop with first x cell array. But there is some error after second iteration, function didn't return true values.
x =
[-4.6250] [-3.5750]
[-3.8750] [-2.2250]
[-3.1250] [-0.8750]
[-2.3750] [ 0.4750]
[-1.6250] [ 1.8250]
[-0.8750] [ 3.1750]
[-0.1250] [ 4.5250]
[ 0.6250] [ 5.8750]
[ 1.3750] [ 7.2250]
[ 2.1250] [ 8.5750]
[ 2.8750] []
[ 3.6250] []
[ 4.3750] []
[ 5.1250] []
[ 5.8750] []
[ 6.6250] []
[ 7.3750] []
[ 8.1250] []
[ 8.8750] []
[ 9.6250] []
My function is
f = cellfun(@(x) x.^2-3.*x+5,x);
I didn't initialize it as array or anything. Error is
Error using cellfun
Non-scalar in Uniform output, at index 31, output 1.
Set 'UniformOutput' to false.
Error in neg (line 1)
f = cellfun(@(x) x.^2-3.*x+5,x);
After I did 'UniformOutput' to false as it said, but then the function didn't return minus values. I want function to work for all x values. I have missing information about cell array. Can you give me any suggestion?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Type Conversion dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!