Plotting multiple data sets on the same polaraxes in AppDesigner

Should I be able to plot 2 or more data sets - e.g., measured and interpolated points - in the same polaraxes ?
I can do this in a plain figure, or GUIDE, using "hold on" and returning a handle from each plot, but I'm not succeeding in AppDesigner(2021b), which I'd like to use because of its clean appearance, ease of use and WYSIWIG screen captures using exportapp.
I'm working from the on-line example:
openExample('matlab/AppdPolarExample')
The code below fails where "plotmark" is defined:
% Define theta. Get a and b
theta = double(0:360)*(pi/180.0);
steps = double(0:10:360)*(pi/180.0); % My new code
a = app.aEditField.Value;
b = app.bEditField.Value;
% Calculate r and plot it
r = (1 + sin(a.*theta)).^(1/b);
s = (1 + sin(a.*steps)).^(1/b); % Also here
plotline = polarplot(app.Pax, theta, r);
plotmark = polarplot(app.Pax, steps, s, 'o', ...
'MarkerFaceColor', 'r', 'MarkerEdgeColor', 'k'); % THE ERROR IS HERE
% Set line color
plotline.Color = app.DropDown.Value;
plotline.LineWidth = 1.5;
The error message is "invalid or deleted object".
Are multiple plots impossible here, or is there a work-around ?

 採用された回答

Kevin Holly
Kevin Holly 2022 年 7 月 18 日
編集済み: Kevin Holly 2022 年 7 月 18 日

1 投票

You can still use hold on in App Designer, but you have to specify the axes.
properties (Access = private)
Pax % Polar axes
end
methods (Access = private)
function updateplot(app)
% Define theta. Get a and b
theta = 0:pi/1800:2*pi;
steps = double(0:10:360)*(pi/180.0); % My new code
a = app.aEditField.Value;
b = app.bEditField.Value;
% Calculate r and plot it
r = (1 + sin(a.*theta)).^(1/b);
s = (1 + sin(a.*steps)).^(1/b); % Also here
plotline = polarplot(app.Pax, theta, r);
hold(app.Pax,"on")
plotmark = polarplot(app.Pax, steps, s, 'o', ...
'MarkerFaceColor', 'r', 'MarkerEdgeColor', 'k');
% Set line color
plotline.Color = app.DropDown.Value;
plotline.LineWidth = 1.5;
end
end

2 件のコメント

Pawel Tokarczuk
Pawel Tokarczuk 2022 年 7 月 18 日
Thanks, that was certainly one issue - without that, stray figures just kept popping up from nowhere.
Also, I needed to populate the app with a lot of properties that wouldn't just be local to the start-up function.
After that, I was able to create my graphs once, then update the RData of each plot to modify the curves in response to parameter changes.
I'm getting used to the operation of AppDesigner now, so thanks for your help. Call this resolved.
Rik
Rik 2023 年 6 月 29 日
Comment posted as flag by Dominique:
a pain solver ! Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

リリース

R2021b

質問済み:

2022 年 7 月 16 日

コメント済み:

Rik
2023 年 6 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by