MATLAB quad and difficulty with vector input

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 5K views
PlasticOh-No
Messages
18
Reaction score
0
MATLAB "quad" and difficulty with vector input

Hello all.

Consider the following:

function y = testf(x,a)
y = sin(pi.*a.*x);

...and then we have

a = 0.05:0.05:1;
result1 = quad(@(x)testf(x, a),0,1)

which crashes with

? Error using ==> times
Matrix dimensions must agree.

Can you help?
Thank you.
 
Physics news on Phys.org


Oops. Is this just a matter of using quadv instead of quad?