How can i generate data randomly in MATLAB
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello Everyone, I hope you are doing well
I have the following code. which generate 5 level of different values.as you can see in plot
I want to generate random level upto 32 for random value from 1 to 1000
How can i do that in matlab
VALUE = [100 300 600 700 1000 ];
out2 = repmat(VALUE,1,ceil(4000/numel(VALUE)));
scatter(1:length(out2),out2)
답변 (1개)
Arif Hoq
2022년 3월 4일
try this:
VALUE=1:(1000-1)/31:1000
out2 = repmat(VALUE,1,ceil(4000/numel(VALUE)));
scatter(1:length(out2),out2);
댓글 수: 14
Walter Roberson
2022년 3월 6일
level = 17; %randi([2 32], 1, 100);
[M,N]=size(level);
for j = 1:size(level,2)
prf=randi([1 1000], 1,level(j));
size(prf)
out = repmat(prf,1,ceil(1000/numel(prf)))
whos
end
Notice that out is length 1003. You cannot reshape() 1003 into 1000.
What you can do is
out = out(1:1000);
and you could reshape() that
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!