Opticalexperimentsgenerallyneedsastableenvironment,highprecisionoftheinstrument,sointheclassroomtodoopticalexperimentisextremelylimited,andalsobytheteachingtimelimit.Inordertoovercometheopticalexperimentonexperimentalconditionsareharshdisadvantages,canusecomputersimulationofopticalexperiment,especiallyopticaldemonstrationexperiments,combinedwiththeory,theopticalcoursesinvolvingmostphenomenadisplayedinfrontofstudents,inordertodeepentheunderstandingofopticalelements.
Thedoubleslitinterferenceoflight,singleslitdiffractionandgratingdiffractionisaveryimportantteachingcontentsinuniversityphysicscoursestudying,occupytheimportantpositionin.Computersimulationofopticalinterferencephenomenonisthephysicalessenceofbetterunderstandingandsupplement.ThispaperusetheMatlabsoftwarecombinedwiththestudyofphysicsoflightinterferenceprinciple,theexperimentofNewton'sringanddoubleslitinterferenceexperimentoflightintensitydistributionoftheprogrammingoperation,thephenomenonoftheexperimentsimulationanimation,andsaveitasadirectcalltotheGIFformatanimationgraph,sothatinavarietyofmediause,canmakethestudentmoreeasytounderstandtheinterferencephenomenon,toteachinghasagoodsupportingrole.