That is a good question. Because your medical history is not available, and because your doctor
must have recommended no strenuous activity for a reason, it is very important that you discuss this question with your doctor. He or she will best be able to tell you whether masturbation is something that is safe to perform or whether based upon your condition you should not be doing this. If your doctor recommended no strenuous activity because of a cardiac reason, then perhaps it would be advisable that you not masturbate as this does increase your heart rate and will likely put some strain on your heart. If there is another cause for your doctor to recommend this to you, then it may be safe to perform this, although again, it is important to discuss this with your doctor as only they will be able to answer this question based upon your personal medical history. Perhaps consider yoga, meditation, deep breathing, or other forms of relaxation if your doctor suggests that you do not masturbate, as these have been shown to improve health and keep people calm when under stress. Consult your physician before beginning any of these relaxation techniques though.