A method for controlling an electrical converter, the electrical converter being adapted for converting a DC voltage ( ν dc) into a multi-phase voltage with at least two voltage levels; the method comprising:);determining a modulating signal vector u abc ∗ from a stator flux reference vector ( ψ s, αβ ∗); determining a switching pattern from the modulating signal vector u abc ∗ via pulse width modulation, the switching pattern comprising a sequence of switching transitions, wherein a switching transitions defines a switch position, at which a phase of the converter is switched from one voltage level to another voltage level, and a transition time instant at which the phase of the converter is switched; wherein the switching pattern is regularly determined at each sampling time instant over a prediction horizon; determining a stator flux error ( ψ s,err,αβ) by subtracting the stator flux reference vector ψ s, αβ ∗ from an estimated stator flux vector ( ψ s,αβ), which is estimated from measurements in the electrical converter; modifying the switching pattern by moving transition time instants of switching transitions of the switching pattern, such that the stator flux error ( ψ s,err,αβ) is minimized; applying a part of the modified switching pattern to the electrical converter; characterized in that the switching transitions of the switching pattern are determined over the prediction horizon by: determining future samples of the modulating signal vector u abc ∗ over the prediction horizon by rotating the modulating signal vector u abc ∗ in the αβ 0-coordinate system with an actual angular frequency to a time instant of the respective future sample; generating a switching transition when a carrier signals crosses a value of the future sample during a time interval of the future sample.);determining a modulating signal vector u abc ∗ from a stator flux reference vector ( ψ s, αβ ∗); determining a switching pattern from the modulating signal vector u abc ∗ via pulse width modulation, the switching pattern comprising a sequence of switching transitions, wherein a switching transitions defines a switch position, at which a phase of the converter is switched from one voltage level to another voltage level, and a transition time instant at which the phase of the converter is switched; wherein the switching pattern is regularly determined at each sampling time instant over a prediction horizon; determining a stator flux error ( ψ s,err,αβ) by subtracting the stator flux reference vector ψ s, αβ ∗ from an estimated stator flux vector ( ψ s,αβ), which is estimated from measurements in the electrical converter; modifying the switching pattern by moving transition time instants of switching transitions of the switching pattern, such that the stator flux error ( ψ s,err,αβ) is minimized; applying a part of the modified switching pattern to the electrical converter; characterized in that the switching transitions of the switching pattern are determined over the prediction horizon by: determining future samples of the modulating signal vector u abc ∗ over the prediction horizon by rotating the modulating signal vector u abc ∗ in the αβ 0-coordinate system with an actual angular frequency to a time instant of the respective future sample; generating a switching transition when a carrier signals crosses a value of the future sample during a time interval of the future sample.