I am new matlab user.
Now, I’am doing my work by using matlab software. but I have problem to improve my code in order to have fast time execution.
right now, I have to make a matrix(A,10,C)) which has the value integer [ 1 10].
currently, I am using logic randperm. here my code :
for c=1:C,
for a=1:A,
result(a,:,c)=randperm(10);
end
end
but when I tried to analyze with profile viewer. That code take a more time.
so I wish that there is someone want to share his/her experience about this.
thanks you.
regard
Here’s an alternate solution but it does not have the nice properties of
randpermregarding the distribution of your random numbers:A quick profile shows that your method takes approximately 1.6e-3 seconds on average when
A = C = 10whereas this method takes 5.6e-5 seconds on average.Note:
Older version of MATLAB won’t support the
~operator. If so, try:and ignore
vals.