caculate required number of cores

and the relative matlab file to draw the figure