Linkdata plots with deployed applications

3 visualizzazioni (ultimi 30 giorni)
Alex
Alex il 19 Set 2024
Modificato: Alex il 20 Set 2024
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?

Risposta accettata

Alex
Alex il 20 Set 2024
Modificato: Alex il 20 Set 2024
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

Più risposte (1)

Taylor
Taylor il 19 Set 2024
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 Commento
Alex
Alex il 20 Set 2024
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

Accedi per commentare.

Categorie

Scopri di più su Graphics Performance in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by