필터 지우기
필터 지우기

How to generate sample Randomly in Matlab

조회 수: 2 (최근 30일)
Med Future
Med Future 2022년 3월 3일
댓글: Walter Roberson 2022년 3월 3일
Hello everyone i hope you are doing well.
I have the following code which generate 4000 sample for a value of 200. and output is the if 1x4000
I want the value to be random from 1 to 1000. and save the result of each value in seperate row
for example value=1 it has 4000 samples in first row, after value=100 it has 4000 samples in second row
value= [200];
Numberofsample = [4000];
output = repmat(value,1,(ceil(sum(Numberofsample)/length(Numberofsample))));

답변 (1개)

Benjamin Thompson
Benjamin Thompson 2022년 3월 3일
>> output = randn(1,4000);
>> size(output)
ans =
1 4000
  댓글 수: 12
Med Future
Med Future 2022년 3월 3일
@Walter Roberson Thanks for the answer.
I have to generate the data for other classes as well. Can i post another question?
Walter Roberson
Walter Roberson 2022년 3월 3일
The method remains the same. Take one random quantity for each "value" and repeat it out to the 4000 or whatever you need.
If the class data is quantized, then you can use a random integer in the range of 1 to the number of quantized values, and use that to index the original data, like
output = repmat( MyCategories(randi(length(MyCategories), length(value), 1), 1, NumberOfCopies);

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

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by