Creating an inputted number of randomised arrays

조회 수: 1 (최근 30일)
Peter
Peter 2023년 4월 30일
댓글: Peter 2023년 4월 30일
Hi there,
Been having some trouble creating an inputted number of arrays if anyone could please help that would be much appreciated.
I've found a way to create a template for the randomised array and am fine with gathering the inputs and conditioning them but I need 10-500 (depending on the input defined as Realisations) of these randomised arrays. Note that the values in the array have to be from 1-365 & have to be of size GS (inputted value).
Thanks
%Creating # of Realisation Arrays:
% Realisations = number of repetitions
% GS = Group size / number of elements
% 365 = max value
% 1 = min value
Randomised_Array = (randi([1,365],1,GS));
  댓글 수: 1
Walter Roberson
Walter Roberson 2023년 4월 30일
cell array in a loop.
or generate all of the random numbers in one call and use num2cell to split the columns into a cell array.

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

채택된 답변

Rik
Rik 2023년 4월 30일
편집: Rik 2023년 4월 30일
Depending on what you want to do next, you can either create a cell vector in a loop, where each element is a matrix, or you can ask randi for a 3D array:
Randomised_Array = randi([1,365],1,GS,Realisations);
Then when you need one instance, you can index this array to select one slice.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by