Set XTick to MATLAB?

I try to set XTickfor each of my subtitles. After reading the MATLAB documentation here , I decided to do the following, but it does not work.

MWE

subplot(2, 1, 1);
gca.XTick = [0, 6, 12, 18, 24];
subplot(2, 1, 2);
gca.XTick = [0, 6, 12, 18, 24];

My version of MATLAB

>> version

ans =

8.4.0.150421 (R2014b)
+4
source share
1 answer

You cannot use gcadirectly as if it were a reference to a descriptor on the left side of an assignment operation. You can use the syntax set(gca, ...)or ax = gca; ax.XTick ..., but only if you avoid the syntax gca.Whatever = ...that breaks down gcain the workspace that you do due to the identifier being obscured.

Syntax

gca.XTick = [0, 6, 12, 18, 24];

, . gca() gca , XTick. , gca, gca , clear ( " ll ).

ax = gca;
ax.XTick = [0, 6, 12, 18, 24];

, gca.XTick = ... .

, Matlab " ": (, set(gca, 'XTick', ...)), , lvalue , .

, gca =, .

whos which. , which, , gca.

function darnit_gca()

disp('gca is:');
which gca

subplot(2, 1, 1);
gca.XTick = [0, 6, 12, 18, 24];
subplot(2, 1, 2);
gca.XTick = [0, 6, 12, 18, 24];

disp('now gca is:');
which gca

darnit_gca, gca , lvalue.

>> darnit_gca
gca is:
built-in (/Applications/MATLAB_R2014b.app/toolbox/matlab/graphics/gca)
now gca is:
gca is a variable.
+6

All Articles