Why can't I use crand() in matlab

4 visualizaciones (últimos 30 días)
Erfan Wu
Erfan Wu el 9 de Dic. de 2019
Comentada: Paul el 30 de Jun. de 2025
It is supposed to generate a complex random number, and it worked on my friend's PC, but not mine.

Respuesta aceptada

per isakson
per isakson el 9 de Dic. de 2019
Editada: per isakson el 10 de Dic. de 2019
>> which crand -all % -all toolboxes that are installed on my PC
C:\Program Files\MATLAB\R2018b\toolbox\robust\rctutil\crand.m
>> help crand
out = crand(dim1,dim2)
Complex random matrix generator: generates a complex,
random matrix with a uniform distribution of dimension
DIM1 x DIM2. If only one dimension argument is given,
the output matrix is square.
See also crandn, rand, randn and sysrand.
But as Star Strider says, it's not in the MATLAB documentation
Star Strider's proposal is worth better than being deleted. Try this:
crand = @(m,n) randn(m,n) + 1i*randn(m,n);
C = crand(2,2)
Experiment to get different results, including with different random number generator functions
  1 comentario
Paul
Paul el 30 de Jun. de 2025
Should use rand (not randn) in the anonymous function.

Iniciar sesión para comentar.

Más respuestas (1)

Bobby Cheng
Bobby Cheng el 30 de Jun. de 2025
Editada: Steven Lord el 30 de Jun. de 2025
rand in MATLAB has complex support since R2022a. See the "Random Complex Numbers" example on that documentation page.
[SL: hyperlinked the function name and added mention of the example.]

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by