MATLAB scripts were designed to compute the sample-limited spatial resolution in transmission electron microscopy (TEM) and scanning TEM (STEM) as a function of different microscopy parameters including the electron dose eD, sample geometry, and materials parameters. The scripts can be used to select the optimum microscopy modality and optimize the experimental conditions to achieve the best possible resolution considering the limitations set by both the electron optics and the examined sample. The resolution can be computed as function of the objective opening semi-angle α for TEM and detector opening semi-angle β for STEM. Optional code for computing a range over the sample thickness t or eD are provided as well, whereby the opening angle is optimized for each data point. The spatial resolution depends on the type of material of the nanoscale object (for example, gold or carbon nanoparticles), the type of matrix holding the objects (for example, water or ice), the depth of the nanoscale object inside the matrix, and eD. The optimization is consistent with the typical situation that carbon nanoparticles are best examined with TEM embedded in a thin matrix (t = 0.1 µm), while STEM is better suited for high atomic number objects such as gold nanoparticles in water, irrespective of t. The script also calculates the reduction of beam broadening in thick samples (t > 1 µm) using bright field STEM.