Linkdata not refreshing graph
I have code for a battery controler i’m making, and as part of that i want to display some live results as it continues running. The whole system runs in a repreating while loop which you can see below(have removed some code to make it legible).
while On = ‘true’
%% Initialise Display
Display = figure(‘Name’,’Controler Display’,’NumberTitle’,’off’);
tiledlayout(2,1)
ax1 = nexttile;
plot(ax1,Display_timebase,Display_Power_cmd, "DisplayName","ESS Power Command (kW)")
title ‘ESS input/output’
hold on
plot(ax1,Display_timebase,Display_Grid_Demand,"DisplayName","Grid Demand")
plot(ax1,Display_timebase,Display_Available_Power, "DisplayName","Available Power (kW)")
ylim([-300 320])
legend
xline(0)
hold off
ylabel("ESS Power in/output")
xlabel("Time")
xlim([-12 48])
ax2 = nexttile;
plot(ax2,Display_timebase,Display_ESS_SoC)
title ‘SoC over time’
ylim([0 1.05])
ylabel("ESS SoC")
xlabel("Time")
xlim([-12 48])
xline(0)
linkdata(Display,’on’)
drawnow
%%%%%%%%%%%
%% Additional Code
%%%%%%%%%%%
%% Update Display values
Display_Power_cmd = [Historical_power_cmd Navigator_Outputs.Power_cmd’];
Display_Grid_Demand = [Historical_Grid_Demand Navigator_Outputs.Grid_Demand’];
Display_Available_Power = [Historical_Available_Power Mapper_Outputs.Available_Power’];
Display_ESS_SoC = [Historical_SoC ESS_SoC_array’];
drawnow
end
I’m aware that being in a while loop suppresses figure updates, hence why i’ve included the drawnows but my figures still refuse to update. What am i doing wrong here?I have code for a battery controler i’m making, and as part of that i want to display some live results as it continues running. The whole system runs in a repreating while loop which you can see below(have removed some code to make it legible).
while On = ‘true’
%% Initialise Display
Display = figure(‘Name’,’Controler Display’,’NumberTitle’,’off’);
tiledlayout(2,1)
ax1 = nexttile;
plot(ax1,Display_timebase,Display_Power_cmd, "DisplayName","ESS Power Command (kW)")
title ‘ESS input/output’
hold on
plot(ax1,Display_timebase,Display_Grid_Demand,"DisplayName","Grid Demand")
plot(ax1,Display_timebase,Display_Available_Power, "DisplayName","Available Power (kW)")
ylim([-300 320])
legend
xline(0)
hold off
ylabel("ESS Power in/output")
xlabel("Time")
xlim([-12 48])
ax2 = nexttile;
plot(ax2,Display_timebase,Display_ESS_SoC)
title ‘SoC over time’
ylim([0 1.05])
ylabel("ESS SoC")
xlabel("Time")
xlim([-12 48])
xline(0)
linkdata(Display,’on’)
drawnow
%%%%%%%%%%%
%% Additional Code
%%%%%%%%%%%
%% Update Display values
Display_Power_cmd = [Historical_power_cmd Navigator_Outputs.Power_cmd’];
Display_Grid_Demand = [Historical_Grid_Demand Navigator_Outputs.Grid_Demand’];
Display_Available_Power = [Historical_Available_Power Mapper_Outputs.Available_Power’];
Display_ESS_SoC = [Historical_SoC ESS_SoC_array’];
drawnow
end
I’m aware that being in a while loop suppresses figure updates, hence why i’ve included the drawnows but my figures still refuse to update. What am i doing wrong here? I have code for a battery controler i’m making, and as part of that i want to display some live results as it continues running. The whole system runs in a repreating while loop which you can see below(have removed some code to make it legible).
while On = ‘true’
%% Initialise Display
Display = figure(‘Name’,’Controler Display’,’NumberTitle’,’off’);
tiledlayout(2,1)
ax1 = nexttile;
plot(ax1,Display_timebase,Display_Power_cmd, "DisplayName","ESS Power Command (kW)")
title ‘ESS input/output’
hold on
plot(ax1,Display_timebase,Display_Grid_Demand,"DisplayName","Grid Demand")
plot(ax1,Display_timebase,Display_Available_Power, "DisplayName","Available Power (kW)")
ylim([-300 320])
legend
xline(0)
hold off
ylabel("ESS Power in/output")
xlabel("Time")
xlim([-12 48])
ax2 = nexttile;
plot(ax2,Display_timebase,Display_ESS_SoC)
title ‘SoC over time’
ylim([0 1.05])
ylabel("ESS SoC")
xlabel("Time")
xlim([-12 48])
xline(0)
linkdata(Display,’on’)
drawnow
%%%%%%%%%%%
%% Additional Code
%%%%%%%%%%%
%% Update Display values
Display_Power_cmd = [Historical_power_cmd Navigator_Outputs.Power_cmd’];
Display_Grid_Demand = [Historical_Grid_Demand Navigator_Outputs.Grid_Demand’];
Display_Available_Power = [Historical_Available_Power Mapper_Outputs.Available_Power’];
Display_ESS_SoC = [Historical_SoC ESS_SoC_array’];
drawnow
end
I’m aware that being in a while loop suppresses figure updates, hence why i’ve included the drawnows but my figures still refuse to update. What am i doing wrong here? figure, linkdata MATLAB Answers — New Questions