跳到正文
Hub Nexus
更新

作者暂无作者认领

发现可以改进的地方?提出一个改动吧。

赞助

此页面是公开的。

MATLAB offers incomparable control over the way you can add details to your plot. From inserting text at the right positions to labelling the axes, MATLAB from the command line offers you an easy way to create publication style graphics. With support for Encapsulated PostScript and Adobe Illustrator output. Complex figures with several axes and conveying large amounts of information can be created.

Concept of a handle

Most operations on figures generate objects with a set of properties. Users familiar with object-oriented programming would realize that the functions and the data are encapsulated into the object. A typical figure would contain at least half a dozen objects. These objects are called handles. A very tacky analogy would be like handles to several different refrigerators with several different contents. To provide an intuitive feel. I have listed out the properties from a text handle.

Finding a handle

Various commands provide required handles, for example:

h = gcf; % Get current figure
h = gca; % Get current axis

Examples

Axis Label

xlabel labels the x-axis of the current plot.

xlabel('string')

You can display text on two lines or insert the value of variables

xlabel({['First Line or line n° ',int2str(a)],['Second Line or line n°',int2str(b)]})

ylabel labels the y-axis of the current plot. It works in same way of xlabel, but the output is vertical in 2D plots.

Documenting a Maximum Value

% Previous code set the x value of the peak data point into x_peak
plot(lags(1:1000:end),abs_cs(1:1000:end));
ptitle = 'UUT and Source Correlation Score Magnitude';
xlabel('Lag'); ylabel('Correlation Magnitude');
title(ptitle); yloc = max(get(gca,'YLim'));
% Put at top of plot
text(lags(x_peak),yloc,[' \leftarrow ' num2str(x_peak) 'ns']);
lstr{1} = sprintf(' Test %d', TESTNUM); lstr{2} = sprintf(' Unit %d%s', UNITNUM, comparestr);
text(lags(1),mean(get(gca,'YLim')),lstr);

Where this page came from

This page was imported from Wikibooks. From “MATLAB Programming” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

收录于这些专栏MATLAB Programming

语言English

许可协议: CC BY-SA 4.0 · 改编自 en.wikibooks.org

观看次数

留言

Spinner Logo
版本: 2CC0 1.0(公有领域)
The runaway star that left the Tarantula Nebula
版本: 2CC0 1.0(公有领域)
The Eagle Nebula, seen in the infrared
版本: 2CC0 1.0(公有领域)
The Cosmic Cliffs are not cliffs
版本: 2CC0 1.0(公有领域)
The recommended targets are real, but the largest health gain is between doing nothing and doing a little. That is the part worth knowing if you are starting from nothing.
版本: 2CC0 1.0(公有领域)
Sleep is not one state but a cycle through several, each doing different work. Most sleep disorders are a failure to complete that cycle rather than a shortage of hours.
版本: 2CC0 1.0(公有领域)
Four nebulae that revealed the shape of our galaxy