Set Resolution of analog-in and analog out using Matlab or Simulink?

Im new to Arduino and dont find an answer on the internet to the following question:

is there a way to change the analog in and pwm resolution using Matlab or Simulink from standart 8 bit to 10 or 12 bit? The I/O block package in Simulink doesnt seem to support this, also the command "AnalogWriteResolution()" doesnt seem to be supported by Matlab. Can you give me a direction how this can be done? Maybe with an S-Function?

The board is a Arduino Due
best regards

you can do oversampling of the 10 bit signal.
to get an extra bit you need to sample 4x as much
2 bits extra => 16x as much samples

check this doc - -

you need to implement this on the Arduino and you can define your own command in MATLAB to send to serial command to the UNO

thank you,

i solved the problem with a s-function.


Can you explain what an S function does?

it is a custom Block in the Software Matlab Simulink.

With the Arduino IDE i have no problem setting the resolution of the a/d converters to 12bit. There i just use the command "analogReadResolution(12)".

But for the Matlab Simulink Support package, there is no option to change resolution. therefore i just made a custom "block" wich contains this command, so i can use it with simulink models.

Hi , Can you share the s function you are using for changing the resolution of due analogRead and analogWrite using simulink. I would be really grateful as i am stuck in the same problem. Thanks a lot