0
votes

I'm trying to run this function like this: calcSQNRA(0,4,6) and I'm getting these errors:

??? Error using ==> mtimes Inner matrix dimensions must agree.

Error in ==> calcSQNRA>@(x)x.^2*e.^(-x) at 6 f = @(x) x.^2 * e.^(-x);

Error in ==> quadl at 70 y = feval(f,x,varargin{:}); y = y(:).';

Error in ==> calcSQNRA at 7 x = 10 * log10(3 * 4^t * quadl(f,xmin,xmax));

function [x] = calcSQNRA(xmin, xmax, N)

e = exp(1);
t = log2(N);

f = @(x) x.^2 * e.^(-x);
x = 10 * log10(3 * 4^t * quadl(f,xmin,xmax));

The function is trying to compute the SQNR of an exponential distribution (if I thought of it correctly), after a uniform quantization. Note that if I erase the e.^(-x) from f it actually produces a result. Any ideas?

1

1 Answers

4
votes

I kill 15 minutes debugging quadl and feval functions. And going so deep in this process I just think about this simple thing:

it just works if I set . in your f anonymous function this way:

f = @(x) x.^2 .* e.^(-x);

then calcSQNRA(0,4,6) give result: 22.1635.

Is it what you want to achieve?