A method for controlling a three-phase electrical converter, the method comprising: selecting a three-phase optimized pulse pattern from a table of precomputed optimized pulse patterns based on a reference flux (ψ αβ,ref); determining a two-component optimal flux ψ αβ ∗ from the optimized pulse pattern and determine a one-component optimal third variable ( ζ *); determining a two-component flux error from a difference of the optimal flux ψ αβ ∗ and an estimated flux (ψ αβ) estimated based on measurements in the electrical converter; determining a one-component third variable error from a difference of the optimal third variable ( ζ *) and an estimated third variable ( ζ); modifying the optimized pulse pattern by time-shifting switching instants of the optimized pulse pattern such that a cost function depending on the time-shifts is minimized, wherein the cost function comprises a flux error term and a third variable error term, wherein the flux error term is based on a difference of the flux error and a flux correction function providing a flux correction based on the time-shifts and the third variable error term is based on a difference of the third variable error and a third variable correction function providing a third variable correction based on the time-shifts; applying the modified optimized pulse pattern to the electrical converter wherein the optimal third variable is a flux; and the optimal third variable is a neutral point flux determined from an optimal neutral point potential integrated over time and the estimated third variable is the corresponding estimated neutral point flux determined from measurements in the converter in case the three-phase electrical converter is a neutral point clamped converter; or the optimal third variable is a flux determined from a circulating current in case the three-phase electric converter is a modular multi-level converter; and a Clarke transformed three-component optimal flux is determined from the optimized pulse pattern and split into the two-component optimal flux and into a one-component flux as optimal third variable. selecting a three-phase optimized pulse pattern from a table of precomputed optimized pulse patterns based on a reference flux (ψ αβ,ref); determining a two-component optimal flux ψ αβ ∗ from the optimized pulse pattern and determine a one-component optimal third variable ( ζ *); determining a two-component flux error from a difference of the optimal flux ψ αβ ∗ and an estimated flux (ψ αβ) estimated based on measurements in the electrical converter; determining a one-component third variable error from a difference of the optimal third variable ( ζ *) and an estimated third variable ( ζ); modifying the optimized pulse pattern by time-shifting switching instants of the optimized pulse pattern such that a cost function depending on the time-shifts is minimized, wherein the cost function comprises a flux error term and a third variable error term, wherein the flux error term is based on a difference of the flux error and a flux correction function providing a flux correction based on the time-shifts and the third variable error term is based on a difference of the third variable error and a third variable correction function providing a third variable correction based on the time-shifts; applying the modified optimized pulse pattern to the electrical converter wherein the optimal third variable is a flux; and the optimal third variable is a neutral point flux determined from an optimal neutral point potential integrated over time and the estimated third variable is the corresponding estimated neutral point flux determined from measurements in the converter in case the three-phase electrical converter is a neutral point clamped converter; or the optimal third variable is a flux determined from a circulating current in case the three-phase electric converter is a modular multi-level converter; and a Clarke transformed three-component optimal flux is determined from the optimized pulse pattern and split into the two-component optimal flux and into a one-component flux as optimal third variable.