OK so here is the problem. In my assignment I should create a (3,1000) matrix and after I created it I should delete RANDOMLY 271 rows of the matrix. At the end I should obtain a (3,729) Matrix with all the initial values except the one I deleted corresponding to the random numbers.
To do so I wrote this script where Mc=1000 N=729
h=1
do a=1, (Mc-N)
call random_number(rand_num)
rand_num=int(rand_num*Mc)-1
!print*, rand_num
do b=1, Mc
if (b /= rand_num) then
NMatrix(:,h) = Matrix(:,b)
h=h+1
else
h=h
endif
enddo
enddo
But when I run it it reports me this error: Program receiver signal SIGABRT : Process abort signal.
What should I do? Please it's really important
I know there is some problem with the do loops and the memory of the arrays, but I cannot get to the point. Can you please ask me?
Here an example ouput of what you are asking for (I think).
Note that by convention, the 1st index is the rows, and the 2nd index is the columns. So you are asking to remove 271 columns from the matrix.
I decided to use an array of index values
indx=[1,2,3,4 .. n], which I shuffle randomly, then slice off the last 271 values (keepnentries) and then sort back to increasing order.Finally, the result is essentially
NMatrix(:,:) = Matrix(:, indx)or in my case I call themaandbin my function.and the sample code to test the above is