Why can't I use crand() in matlab

조회 수: 6 (최근 30일)
Erfan Wu
Erfan Wu 2019년 12월 9일
댓글: Paul 2025년 6월 30일
It is supposed to generate a complex random number, and it worked on my friend's PC, but not mine.

채택된 답변

per isakson
per isakson 2019년 12월 9일
편집: per isakson 2019년 12월 10일
>> 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
Paul
Paul 2025년 6월 30일
Should use rand (not randn) in the anonymous function.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Bobby Cheng
Bobby Cheng 2025년 6월 30일
편집: Steven Lord 2025년 6월 30일
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.]

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by