Linkdata plots with deployed applications

2 次查看(过去 30 天)
I have a code which im looking to deploy using the matlab application compiler. My code involes a plot with linked data so i can have a live update of my output. The problem is that a plots cannot be linked in deployed applications because linked plots require the MATLAB workspace which is not available when code is deployed.
Are there ways around this or alternatives that i can use to keep the updating plots while havng my code deployable?

采纳的回答

Alex
Alex 2024-9-20
编辑:Alex 2024-9-20
I found a workaround which is to use animated lines which do not directly reference the workspace so work even when passed through the application compiler.
timebase = -pi:0.01:(4*pi);
Display = figure('Name','Animated lines','NumberTitle','off');
h = animatedline(timebase,sin(timebase));
hold on
j = animatedline(timebase,sin(timebase));
ylim([-1 1]);
title('Title')
legend
hold off
for x=0:0.01:100
clearpoints(h)
clearpoints(j)
values2 = 0.5*sin(timebase+x);
values = sin(x)*values1;
addpoints(h,timebase,values)
addpoints(j,timebase,values2)
drawnow
end

更多回答(1 个)

Taylor
Taylor 2024-9-19
Is this what you're looking for? You can really see the behavior here, so copy, paste, and run the first section into your MATLAB, and then copy, paste, and run the second section to see how the plot updates.
x = 0:.1:4*pi;
y = sin(x);
figure;
h = plot(x, y);
h.XDataSource = "x";
h.YDataSource = "y";
y = cos(x);
refreshdata
Also, I don't think "The problem is that a plots cannot be linked in deployed applications because linked plots require the MATLAB workspace which is not available when code is deployed" is necessarily accurate. There is a workspace for compiled applications, you just don't really have direct access to it. linkdata is not supported for Compiler though.
  1 个评论
Alex
Alex 2024-9-20
Thank you for your help but that did not work i'm afraid. the line "Plots cannot be linked in deployed applications because linked plots require the MATLAB workspace" was the error message i got when i tried to run the code after compiling it using the application compiler. Im assuming this is part of the reason why linkdata is not supported by the compiler then.
I did find a workaround which is to use animated plots which do not reference the worspace directly and therfore work when compiled

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Application Deployment 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by