What does gca mean?

12 views (last 30 days)
michelle Ormanns
michelle Ormanns on 8 Nov 2016
Commented: John D'Errico on 18 Aug 2024
hello together, I'm a Beginner and I have a friends' skript and I'm trying to understand it.
1.)I don't really understand the "set"/"get" programmation als well as the "gca"/the "1" in the first line...
2.) Furthermore I didn't understand what the: {\it t} stands for (last line)...
for a Diagramm he wrote:
set(gca,'XGrid','on', 'YGrid', 'on', 'Fontsize', 16, 'linewidth', 1)
x_axis = get(gca, 'xtik');
xlabel('time{\it t} [s]')
I've already been searching for this question, but too many other questions without any correlation to this theme were found...
Thanks!

Answers (2)

Jan
Jan on 8 Nov 2016
Edited: Jan on 8 Nov 2016
I agree with John: Only reading the manual will really help.
But this is a forum for Matlab related questions and all questions are welcome. Therefore:
gca replies the "handle" of the currently active axes object. A "handle" is a kind of address to identify all graphic objects. With set and get you can change or obtain properties of the graphic object.
Try this in the command window:
H = axes
get(H)
get(H, 'XColor')
set(H, 'XColor', [1,0,0]);
get(H, 'XColor')
'{\it t}' is a LaTeX string, which displays the "t" in italics. Search for "latex" in the documantation:
docsearch latex
Note that "get(gca, 'xtik')" will fail, because the property is called "xtick".

John D'Errico
John D'Errico on 8 Nov 2016
Edited: John D'Errico on 8 Nov 2016
Is there a reason why you would not just try
help gca
or better,
doc gca
RTFM. When you have a question about a MATLAB function, the fastest way to answer the question is by using the existing help. Well written, by professionals.
gca: Get handle to current axis.
I think your real problem is you have no idea how handle graphics works, based on your comments. Again, read the help. The help docs discuss the concept of "Graphics Objects".
  3 Comments
Walter Roberson
Walter Roberson on 18 Aug 2024
This message is discouraging the OP and others from asking questions and is rather talking about how stupid and illiterate the OP is. No one is perfect and forums exist for all questions , while help and doc do help , its not always understandable especially for a beginner , so other the rant , explanation could have been done.
John D'Errico
John D'Errico on 18 Aug 2024
I'm sorry, but I disagree. It points out that the very best and fastest way to get an explanation for some function is to use the help already provided in MATLAB. You get an answer immediately, complete with mutliple examples, especially if you use the doc facility in MATLAB. This is certainly true for GCA.
In the case of the second question: 2.) Furthermore I didn't understand what the: {\it t} stands for (last line)... The answer is probably less obvious.

Sign in to comment.

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!