Setting to use matlab `integral` with a (only) scalar function? -


i have function cannot written take vector input , return vector output. builtin integral function seems expect this, , evaluating number of locations @ same time. there way turn off?

i.e., simplest test case is

f = @(x) x * x; % intended univariate integral(f, 0, 1); %i want have call univariate inputs. 

where purposefully not setting function x .* x in order test univariate input. obviously, function lot more complicated , cannot vectorized.

you can use array-valued flag that's mentioned in help:

>> f = @(x) x * x; >> integral(f,0,1,'arrayvalued',true)  ans =      0.3333 

the description bit misleading:

array-valued function flag, specified comma-separated pair consisting of 'arrayvalued' , either false, true, 0, or 1. set flag true indicate fun function accepts scalar input , returns vector, matrix, or n-d array output.

the default value of false indicates fun function accepts vector input , returns vector output.

so notice doesn't explicitly specify input scalar , output scalar, it's clear intent use scalar input.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -