How do I convert a cell array of char to a single plot title?

조회 수: 6 (최근 30일)
Paul Fishback
Paul Fishback 2015년 5월 19일
댓글: Paul Fishback 2015년 5월 19일
I have a 3-by-1 cell, call it "labels," each of whose entries is a char. For example, labels{1,1}=A1,A2,A3 labels{2,1}=B1,B2,B3,B4 labels{3,1}=C1,C2
I would like to create a multi-line plot title using the content of each label cell on a different line. Specifically, the title would look as follows:
A1,A2,A3
B1,B2,B3,B4
C1,C2

채택된 답변

Titus Edelhofer
Titus Edelhofer 2015년 5월 19일
Hi,
use sprintf to add a carriage return at the end of each line:
title(sprintf('%s\n', labels{:}))
Titus

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by