How can I output a matrix of row time vectors from the Simulink block "Interpreted Matlab function"?

2 views (last 30 days)
I'm trying to simulate the operation of a microgrid during a day in Simulink (phasor mode); I operate the optimization throught Matalab, using Yalmip and solving with Gurobi, and feed the time vectors of the machines power (generators, battery and PV) to Simulink. Then my intention is to check for changes in the load and if the value change to re-operate the optimization feeding the new value to the matlab file and obtaining back other TIME vectors (meaning 1x24), one for each machine. To do this I use the "Interpreted Matalb function" but I'm anable to get back a matrix of time vectors (N_machinex24) or just one vector, the maximum I got back was a lump of all the values together,not linked to one another. Still I need the time vectors, I cant just get I value at a time for each machine and re-run the function cause I have costs that depend on startup and re-doing the calculation for every hour (instead that for the day) would overshadow them. I also tried to save the values in the matlab workspace using "assignin" but it just stores there a value and not the entire vector (even if the program produce vectors just fine when it s not in the "INTERPRETED MATLAB FUNCTION").
Thank you if you have the patience to help me, I'm attaching the folder to open and run the simulation: open first the simulink library, run the EMS matalb file and last open and run the simulink simulation.
function [Results] = InternalEMS2(Values)
...
%decisional variables
P_gen=sdpvar(N_gen,ssize); % [kW] power required from each generator
...
%stating of constraints and objective function
%solving
optimize(Constraints, Objective,ops);
...
%assigning values to the solutions
solution_P_gen_1=value(P_gen(1,:)); %1x24
...
%output of the function
Results=[solution_P_gen_1; solution_P_gen_2; solution_P_gen_3; solution_P_gen_4; solution_P_gen_5; solution_y_gen_1; solution_y_gen_2; solution_y_gen_3; solution_y_gen_4; solution_y_gen_5; solution_P_pv; solution_P_bat];
end

Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!