'How to minimize noise in Simulink

I am running the simulation of a very nonlinear system using simulink, but the solutions of the system are not very accurate. Some people said that the solver can be accumulating errors but I do not know how to fix this error accumulation. The system that I am simulating is a boost converter with pulse current.

enter image description here

enter image description here

The code that I am suing is:

clear all;

clear;

close all;

RL=0.1;

L=10E-3;

c=100E-6;

Rc=50;

l=0.5  % Lambda;

P=5000  % Power;

dc=0.4  % Duty cycle of the PWM signal;

T=0.14  % Period of the PWM signal;

Stime=T % Simulation time;

ST=1E-5 % Smapling time;

sim('test3'); % simulink file 

% Plot of the capacitor's voltage
plot(ans.tout,ans.Vc.signals.values,"LineWidth",1.0)
grid on
xlim([x1,x2])
title("")
ylabel("Vc",'FontWeight',"bold")
xlabel("Time (sec)","FontWeight","bold")

My problem is that my answer Vc has rare switches/noise/error when I increase the duty cycle of the PWM signal, and this affect the rest of the system behavior. You can observe the noise/error in the following image.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source