The first figure below shows the MATLAB/Simulink model of a low-pass filter (LPF). The cut-off frequency of the LPF is fc=10Hz. The sinewave frequency is fe=2Hz. As shown in the 2nd figure below, the LPF introduces a phase error at fe=2Hz, resulting in a filtered sinewave with phase error (see 3rd figure below).
Is there a method to compensate the phase error (which is applicable in Simulink or a microcontroller based application)?
are you really sure that your application requires to compensate this phase "error" ?
By the wy, I wouldn´t call it "error" because it is a natural physical phenomenon, see Bode`s fundamental formula for the gain-phase relationship.