Value in m.file does not update with new value presented in simulink
Show older comments
In simulink i have a battery system which i would like to monitor using the MATLAB function block. I am using a combination of if and while to monitor certain parts of the system. Unfortunately when the program reaches into the while in order to monitor a parameter in simulink (which is continuously changing), this parameter is not being updated in my m.file meaning that it stays in the loop indefinitely. Is there a way to solve this issue. I included i piece of the code which I'm using as debug at the moment
function [DL_o, PV_o, LS_o] = fcn(SOC, DL, PV, LS)
DL_o = 1;
PV_o = 0;
LS_o = 0;
if ((SOC>=95) && (DL==1) && (PV==0))
disp('Initialization complete')
if ((SOC>20) && (SOC<=100))
disp('System oke')
if (SOC<=95)
disp('Battery charging may start')
if (DL==1)
disp('Dump is OFF')
if (SOC>=99)
disp('Battery is oke')
else
while (SOC<99)
disp('Battery charging (normal)')
if (SOC>=99)
break
end
end
end
end
end
end
end
Accepted Answer
More Answers (0)
Categories
Find more on General Applications in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!