You can set a var, in this case I used "isExpanded" then use it to open and close set the boolean value.
If you want to use it with the integrated toogle button instead you must update the "isExpanded" var with the "(opened)" and "(closed)" hooks from mat-expansion-panel.