Plot polars in app designer

2 ビュー (過去 30 日間)
Antoine Purier
Antoine Purier 2021 年 5 月 6 日
コメント済み: Antoine Purier 2021 年 5 月 6 日
Hi everyone,
I am creating an app in which I want to plot polars.But I have difficulties plotting anything.
My app consists of one main figure in which I have created a panel to hold my polar axes since there is no such axes object available in the app designer component library.
Here is what I have done so far:
  • I start by creating my polar axes in a startup function and assign these axes to the panel I have created
function startupFcn(app)
app.pax = polaraxes(app.PolarsPanel)
.
.
.
.
end
  • Later on, after a calculaton button push, I call a plot function in which I pass, among other things, the app.pax axes
  • Inside this plot function, I calculate the polars and plot them as follows
polarplot(app.pax,angleValues,horizontalPolar);
hold on
polarplot(app.pax,angleValues,verticalPolar);
legend(legendLabels)
Doing that, it seems to plot something in my panel (not what I want but it seems to do something) but it also opens a new figure on top of my main (and only) app figure.
I do not want that.
Do you guys have any idea of what I am doing wrong here?
After that, I will try to do the same thing in another panel with the patternCustom function to plot 3D-balloons but again, nothing provided in the app designer compenents library...
Thanks a lot in advance
Antoine

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 5 月 6 日
編集済み: Cris LaPierre 2021 年 5 月 6 日
Support for PolarAxes in app designer was added in R2018b. What version of MATLAB are you using?
Perhaps the example 'Create Polar Axes Programmatically in an App' is what you are looking for?
You might also find the 'Plot on Polar Axes' example code given under this Create Axes Programmatically section helpful.
  2 件のコメント
Antoine Purier
Antoine Purier 2021 年 5 月 6 日
Hi Cris,
Thanks for your answer. I had actually already seen that example but it didn't work for me at first.
I tried to change my strategy and focus my function on returning the polars rather than computing them and plotting them.
After I successfully return my polars, I plot everything like below:
%% Plot polars
angleValues = deg2rad([0:app.angularResolution:360]);
horizontalPolarLine = polarplot(app.pax1, angleValues, horizontalPolar);
horizontalPolarLine.Color = 'r';
verticalPolarLine = polarplot(app.pax1, angleValues, verticalPolar);
verticalPolarLine.Color = 'b';
app.pax1.ThetaTick = [0 : 30 : 360];
app.pax1.RLim = [-60 10];
app.pax1.RTick = [-60 : 10 : 10];
set(app.pax1, 'ThetaZeroLocation', 'top');
legend(app.pax1, {'Horizontal','Vertical'})
It works fine this way, in the sense where it doesn't open a new figure anymore.
BUT, it seems to only plot one of the two polars.
I tried adding "hold on" after the first one but doing that creates a new figure automatically for some reason.
Antoine Purier
Antoine Purier 2021 年 5 月 6 日
Ok sorry for being silly, I just changed
hold on
to
hold(app.pax1,"on")
And it works fine!
Thanks a lot for your help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by