how can i get two variables to meet the target SOC which is calculated from simulink.
1 次查看(过去 30 天)
显示 更早的评论
open_system(mdl)
soc_target = 78.6
off_line = 3000
on_line = 7000
sim(mdl);
while true
sim(mdl);
soc_fin = ans.soc_fin;
if abs(soc_fin(end)-soc_target) <= 1.5
break;
end
on_line = on_line + 1000;
end
on_line
off_line
while true
sim(mdl);
soc_fin = ans.soc_fin;
if soc_fin(end)-soc_target < -0.1
off_line = off_line - 100;
elseif soc_fin(end)-soc_target > -0.1
off_line = off_line + 100;
else abs(soc_fin(end)-soc_target) <= 0.1
break
end
end
on_line
off_line
while true
sim(mdl);
soc_fin = ans.soc_fin;
if soc_fin(end)-soc_target < -0.01
off_line = off_line - 10;
elseif soc_fin(end)-soc_target > -0.01
off_line = off_line + 10;
else abs(soc_fin(end)-soc_target) <= 0.01
break
end
end
on_line
off_line
above code is mine that to find
variables on_line & off_line is a number and in simulink model, SOC will be calculated.
when the variables increase, SOC will be decreased,
As variables increase, the soc value decreases, and similarly, as variables decrease, the soc value increases.
i want find two variables to meet SOC target
i'm newly user of matlab so my code is poor
please help.
0 个评论
回答(1 个)
Ram Prasanth
2024-4-19
One idea is to integrate your code in the s-function in your simulink file.
Through this idea you can update your variable and your simulink file will run along with the updated values.
You can find the documentation for it in this link - What Is an S-Function? - MATLAB & Simulink - MathWorks France.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Naming Conventions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!