How do I determine the length of the input vector to quad?
2 次查看(过去 30 天)
显示 更早的评论
I am trying to use quad instead of sum to obtain a more realistic model. The function for quad is of the form
f(E) * exp(-constant*g(E)*variable) * h(E)
for integration variable E (which I suppose is supplied as a vector by quad), variable set prior to quad execution (I could use a vector or scalar and stick quad in a loop, I suppose: it's a scalar, specifying depth), and functions f g and h which interpolate via interp1 for the input E. I encounter matrix mismatch errors:
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Can you tell me why this error results? My current understanding is that this integration variable E vector supplied by quad is a vector of some length, whose length changes iteratively until the result is accurate to within the default 10^-6 tolerance (or whatever tolerance I would specify). Is it not possible to call functions within quad to interpolate values? I'm trying to interpolate while quad is integrating -- is this possible? It seems a very simple thing.
0 个评论
回答(1 个)
Walter Roberson
2012-2-10
f(E) .* exp(-constant .*g(E) .*variable) .* h(E)
What kind of interpolation are you doing inside of f() and h() ? Unless it is at least quintic (5th order), you will not be able to gain any accuracy by interpolating, if I understand the algorithms correctly.
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!