Linkdata plots with deployed applications

3 ビュー (過去 30 日間)
Alex
Alex 2024 年 9 月 19 日
編集済み: Alex 2024 年 9 月 20 日
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 Center および File ExchangeApplication Deployment についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by