use rand in editor

I was given a script to edit with the function "randi" in it, i have a older version of matlab R14. It worked on the latest version, curious if there is n easy conversion to fix this issue.

3 Kommentare

Image Analyst
Image Analyst am 7 Apr. 2012
Are you saying that you got a script with randi() in it from someone who uses R2012a, but you don't have randi() in your older version of MATLAB and so you want some code that does essentially the same thing?
David bondi
David bondi am 7 Apr. 2012
yea that is right
David bondi
David bondi am 7 Apr. 2012
if i change the randi() to rand() which my version can handle it errors with matrix not being the same and rendering mesh

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 7 Apr. 2012

0 Stimmen

You can define your own randi like this:
function out = randi(iMax, rows, columns)
out = int32(floor(iMax*rand(rows, columns) + 1));
Of course that is not as flexible in the types of input arguments that the real randi() accepts, but you can work on that if you want.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 7 Apr. 2012

Community Treasure Hunt

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

Start Hunting!

Translated by