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

2 次查看(过去 30 天)
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

采纳的回答

Sam Chak
Sam Chak 2023-8-31
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

更多回答(0 个)

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by