File Exchange

image thumbnail

Poissrnd

version 1.0 (6.39 KB) by

Speed optimized version of poissrnd

7 Downloads

Updated

No License

Replaces poissrnd.

Improved speed when argument consists of many, wide ranging values.

Comments and Ratings (3)

louisa ip

It's in the MatLab reference; "break is not defined outside a for or while loop. Use return in this context instead." =P

louisa ip

Jarek is right, there are some issues, I'm not sure why the "break" statement doesn't work except maybe the function is expecting an output, so a "return" is needed. Other issues:

1) Rename Poissrnd.m to poissrnd.m, MatLab likes cases to match between the function name and the file, that should fix of Jarek's #4 issue.
2) On line 136, a "(" is misplaced, replace "if prod(size(lambda) == 1)" with "if prod(size(lambda)) == 1". This way, you are comparing the product of the row and column size of lambda to 1. The original line is trying to compare size of lambda to 1, but take the product of the comparison; which is not a correct input argument for "prod".

Other than that, thanks, saved me a trip home getting the file.

jarek tuszynski

Good useful code with many small annoyances. Needs tinkering to get to work. Some problems I run into with R2006a:
1) Error in line 82 a BREAK statement appeared has to be replaced with RETURN.
2) Error in line 136: something about 'prod' is not defined 'logical' values. To fix replace the whole ?prod()? statement with 0.
3) Name conflict with Matlab?s poissrnd ? had to rename function to something else to get to work without warnings.
4) Poissrnd(0) returned NaN while poissrnd(0) returned 0. More changes needed to fix.

After all those changes code worked fine.

MATLAB Release
MATLAB 6.1 (R12.1)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video