www.gusucode.com > symbolic 源码程序 matlab案例代码 > symbolic/AddTitleAndAxisLabelsAndFormatTicks3DImplicitEquationExample.m
%% Add Title and Axis Labels and Format Ticks % Plot the implicit equation $x \sin(y) + z \cos(x) = 0$ over the interval $(-2\pi, 2\pi)$ for all axes. % % Create the x-axis ticks by spanning the x-axis limits at intervals of % |pi/2|. Convert the axis limits to precise multiples of |pi/2| by using % |round| and get the symbolic tick values in |S|. Display these ticks by using the % |XTick| property. Create x-axis labels by using % |arrayfun| to apply |texlabel| to |S|. Display these labels % by using the |XTickLabel| property. Repeat these steps for the y-axis. % % To use LaTeX in plots, see <docid:symbolic_ug.f2-234358>. syms x y z eqn = x*sin(y) + z*cos(x); fimplicit3(eqn,[-2*pi 2*pi]) title('xsin(y) + zcos(x) for -2\pi < x < 2\pi and -2\pi < y < 2\pi') xlabel('x') ylabel('y') ax = gca; S = sym(ax.XLim(1):pi/2:ax.XLim(2)); S = sym(round(vpa(S/pi*2))*pi/2); ax.XTick = double(S); ax.XTickLabel = arrayfun(@texlabel,S,'UniformOutput',false); S = sym(ax.YLim(1):pi/2:ax.YLim(2)); S = sym(round(vpa(S/pi*2))*pi/2); ax.YTick = double(S); ax.YTickLabel = arrayfun(@texlabel, S, 'UniformOutput', false);