Subscript indices must either be real positive integers or logicals

1 次查看(过去 30 天)
Hi all,
I'm trying to do the following:
% simulate a Poisson process with rate \lambda = 3/2
lambda = 3/2;
% MATLAB function poissrnd uses the waiting time method
random_sample = poissrnd(lambda, 1, 4000)
% estimate the distribution
p = poisscdf(random_sample, lambda)
% plot the distribution
x = min(random_sample):1:max(random_sample)
y = double(poisscdf(x, lambda))
z = x+1
plot(z,y)
but I keep getting this error message. Does anyone know what could the problem be?
Thanks a lot!
  2 个评论
Jan
Jan 2012-12-28
Please post a copy of the error message, which reveals e.g. the line, which causes the error.
Nina
Nina 2012-12-29
Actually, it worked well after I tried to run it again. Thanks for your time!

请先登录,再进行评论。

采纳的回答

Jan
Jan 2012-12-28
编辑:Jan 2012-12-28
I can guess only at the moment, that one of the commands has been defined as variable before, e.g. poissrnd, poisscdf, min, max, double or plot. The standard procedure to locate the problem is using the debugger:
dbstop if error
Then run your program again until Matlab stops in the line, which causes the error. Now let which min -all or whatever commands are used in the line show you the definition of the symbols. In general, avoid to use names of built-in functions as names of variables, because this causes problems frequently.

更多回答(0 个)

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by