Clear Filters
Clear Filters

How to convert simulink based Reinforcement learning environment to function or script based.

2 views (last 30 days)
Hi
I followed water tank model for reinforcement learning.
Since it is based on simulink , is there a way to implement this example in function or script based. I do not intend to use simulink.
Looking forward to hear from you.
Thanks
Chetan

Accepted Answer

Sam Chak
Sam Chak on 31 Aug 2023
I believe you can create a MATLAB function to describe the water level in a pump-driven storage tank, and then utilize it to construct the MATLAB Reinforcement Learning Environment.
tspan = [0 20];
h0 = 0.2; % initial height of water level
[t, h] = ode45(@watertank, tspan, h0);
plot(t, h), grid on
xlabel('Time'), ylabel('Water level')
% Water Tank System
function dhdt = watertank(t, h)
A = 1; % cross-sectional area of the tank
a = 1; % constant related to the flow rate out of the tank
b = 1; % constant related to the flow rate into the tank
V = 1; % voltage applied to the pump
dhdt = - a/A*sqrt(h) + b/A*V;
end

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!