Good day all,
I am new here and I am trying to implement a heapsort algorithm in Simulink using heapsort algorithm through a MATLAB function. The input to the function is from a mux block which combines voltage measurement from two capacitors; and the output goes to a demux which is fed to a switching function that generates the pwm signal. However, I am getting the following error when I run the model:
[Simulink error](https://i.stack.imgur.com/JIkCb.png)
I have tried sorting out the issue to no avail. below is the heapsort algorithm
[heapsort algorithm](https://i.stack.imgur.com/Wx866.png)
Below is the switching algorithm that generates PWM pulses
[Switching Function](https://i.stack.imgur.com/TVcIH.png)
I'll be grateful if I get assistance on how to clear the error and get the simulation to work
I continuously adapted the code to no avail. however, using Simulink's built in sort block, I was able to sort the capacitors voltages into index form and generated output voltage and current.