Перейти к содержимому
Hub Nexus
АвторАвтора пока нетВзять себе

Есть что улучшить? Предложите правку.

Поддержка

Эта страница общедоступна.

Cell arrays are the easiest way to generate new lines when using the functions xlabel, ylabel, zlabel, text, title, and gtext. However, cell arrays do not always work (see next section).

When displaying text on plots, "\n" is typically interpreted as '' followed by 'n' instead of the newline character. To generate multiple lines, use cell arrays. This is done by separating each string line of text with a comma and enclosing all comma-separated strings in curly braces as follows.

>> title({'First line','Second line'})

Sometimes it is nice to put the value of a variable and a newline into the plot title.
You can do this like so:

n = 4;
x = -n:1:n;
y = x.^2;
plot(x,y)
title( { 'plot of x squared', 10, 'from x = ', num2str(-n), ' to x = ', num2str(n) } )

The 10 outside the single quotes is the ascii value for a newline. You don't have to use the char() function, just the number will work.

The output should look like this:

plot of x squared
from x = -4 to x = 4

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