gca function in matlab

26 ビュー (過去 30 日間)
civs
civs 2014 年 8 月 20 日
I have read the matlab docs but I don't understand what gca really does. Can somebody explain it to me? Thanks!

採用された回答

Iain
Iain 2014 年 8 月 20 日
gca returns the handle to the current axis. - it generates one if there is no current axis.
  4 件のコメント
civs
civs 2014 年 8 月 20 日
Michael, thanks for the answer! it's clear now :)
Shashibhushan Sharma
Shashibhushan Sharma 2018 年 4 月 19 日
I use the command to plot matlab figure. I also use the code
set (gca)
d=axes('position',get(gca,'position'),'visible','off');
but there are so many things comes in command window. I afraid with these. Are these any problem in plotting the matlab figure?
These are
ALim: {}
ALimMode: {'auto' 'manual'}
ActivePositionProperty: {1×2 cell}
AmbientLightColor: {1×0 cell}
Box: {'on' 'off'}
BoxStyle: {'full' 'back'}
BusyAction: {1×2 cell}
ButtonDownFcn: {}
CLim: {}
CLimMode: {'auto' 'manual'}
CameraPosition: {}
CameraPositionMode: {'auto' 'manual'}
CameraTarget: {}
CameraTargetMode: {'auto' 'manual'}
CameraUpVector: {}
CameraUpVectorMode: {'auto' 'manual'}
CameraViewAngle: {}
CameraViewAngleMode: {'auto' 'manual'}
Children: {}
Clipping: {'on' 'off'}
ClippingStyle: {1×2 cell}
Color: {1×0 cell}
ColorOrder: {}
ColorOrderIndex: {}
CreateFcn: {}
DataAspectRatio: {}
DataAspectRatioMode: {'auto' 'manual'}
DeleteFcn: {}
FontAngle: {1×2 cell}
FontName: {}
FontSize: {}
FontSmoothing: {'on' 'off'}
FontUnits: {1×5 cell}
FontWeight: {'normal' 'bold'}
GridAlpha: {}
GridAlphaMode: {'auto' 'manual'}
GridColor: {1×0 cell}
GridColorMode: {'auto' 'manual'}
GridLineStyle: {1×5 cell}
HandleVisibility: {1×3 cell}
HitTest: {'on' 'off'}
Interruptible: {'on' 'off'}
LabelFontSizeMultiplier: {}
Layer: {'bottom' 'top'}
LineStyleOrder: {}
LineStyleOrderIndex: {}
LineWidth: {}
MinorGridAlpha: {}
MinorGridAlphaMode: {'auto' 'manual'}
MinorGridColor: {1×0 cell}
MinorGridColorMode: {'auto' 'manual'}
MinorGridLineStyle: {1×5 cell}
NextPlot: {1×4 cell}
OuterPosition: {}
Parent: {}
PickableParts: {1×3 cell}
PlotBoxAspectRatio: {}
PlotBoxAspectRatioMode: {'auto' 'manual'}
Position: {}
Projection: {1×2 cell}
Selected: {'on' 'off'}
SelectionHighlight: {'on' 'off'}
SortMethod: {1×2 cell}
Tag: {}
TickDir: {1×3 cell}
TickDirMode: {'auto' 'manual'}
TickLabelInterpreter: {1×3 cell}
TickLength: {}
Title: {}
TitleFontSizeMultiplier: {}
TitleFontWeight: {'normal' 'bold'}
UIContextMenu: {}
Units: {1×6 cell}
UserData: {}
View: {}
Visible: {'on' 'off'}
XAxis: {}
XAxisLocation: {1×3 cell}
XColor: {1×0 cell}
XColorMode: {'auto' 'manual'}
XDir: {1×2 cell}
XGrid: {'on' 'off'}
XLabel: {}
XLim: {}
XLimMode: {'auto' 'manual'}
XMinorGrid: {'on' 'off'}
XMinorTick: {'on' 'off'}
XScale: {'linear' 'log'}
XTick: {}
XTickLabel: {}
XTickLabelMode: {'auto' 'manual'}
XTickLabelRotation: {}
XTickMode: {'auto' 'manual'}
YAxisLocation: {1×3 cell}
YColor: {1×0 cell}
YColorMode: {'auto' 'manual'}
YDir: {1×2 cell}
YGrid: {'on' 'off'}
YLabel: {}
YLim: {}
YLimMode: {'auto' 'manual'}
YMinorGrid: {'on' 'off'}
YMinorTick: {'on' 'off'}
YScale: {'linear' 'log'}
YTick: {}
YTickLabel: {}
YTickLabelMode: {'auto' 'manual'}
YTickLabelRotation: {}
YTickMode: {'auto' 'manual'}
ZAxis: {}
ZColor: {1×0 cell}
ZColorMode: {'auto' 'manual'}
ZDir: {1×2 cell}
ZGrid: {'on' 'off'}
ZLabel: {}
ZLim: {}
ZLimMode: {'auto' 'manual'}
ZMinorGrid: {'on' 'off'}
ZMinorTick: {'on' 'off'}
ZScale: {'linear' 'log'}
ZTick: {}
ZTickLabel: {}
ZTickLabelMode: {'auto' 'manual'}
ZTickLabelRotation: {}
ZTickMode: {'auto' 'manual'}
>> my code to plot the matlab figure given below as: if (Ps==Ps1(1)) yyaxis left T1=semilogy(Bi,sop_si,'*'); grid on;hold on; T2=semilogy(Bi,sop_th,'-'); grid on;hold on; xlabel('Power Splitting Factor for Energy Harvesting, (\beta)'); ylabel('Secrecy Outage Probablity');
yyaxis right
T3=semilogy(Bi,p_out_si,'>');
grid on;hold on;
T4=semilogy(Bi,p_out_th,'-');
grid on;hold on;
ylabel('Harvested Power Outage Probability')
else
yyaxis left
D1=semilogy(Bi,sop_si,'*');
grid on;hold on;
D2=semilogy(Bi,sop_th,'-');
grid on;hold on;
yyaxis right
D3=semilogy(Bi,p_out_si,'>');
grid on;hold on;
D4=semilogy(Bi,p_out_th,'-');
grid on;hold on;
d=axes('position',get(gca,'position'),'visible','off');
legend([T1 T2 D1 D2],'Simulation, P_S=5 dBW, SOP', 'Analytical, P_S=5 dBW, SOP','Simulation, P_S=10 dBW, SOP', 'Analytical, P_S=10 dBW, SOP','Location','NorthEastoutside');
legend(d,[T3 T4 D3 D4],'Simulation, P_S=5 dBW, HPOP', 'Analytical, P_S=5 dBW, HPOP','Simulation, P_S=10 dBW, HPOP', 'Analytical, P_S=10 dBW, HPOP','Location','EastOutside');

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

その他の回答 (1 件)

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014 年 8 月 20 日
Hi Civs,
To my knowledge whenever an object is created (figure, window, axes, function,...) a handle is associates to the object it's like when you want do define a number value, you assign it to a variable,
a = 2;
when you create a figure, axes and ... you can assign them to a variable(handle)
h = figure()
I = axes()
so when you want to plot on a specific axes, let's say you have 10 figures and axes open, and you want to plot on an axes you previously names regression
regression = axes(); % this creates an axes and name it regression
plot(regression,x,y); % this plots on the axes named regression not the other ones
to find which axis is currently viewing or which one is recently clicked (viewed), or more programmatically speaking has the focus, you can use gca which gives you the handle(assume it as variable) to the current figure.
read more about handles it's useful.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by