read text and put it in the title

I want to have a text as an input of a function test.m such that
function test(x,y,title_number, title_name)
plot(x,y)
end
Suppose I choose
test(x,y,1, temperature)
I want to have the title of the plot as
Figure 1. Temperature
Then I want to understand how to write title like
title(['Figure ',num2str(figurenumber),':]
Please advise.

4 Comments

Have you read the documentation for the figure object? You cen set several properties, including the name.
Thank you. What is a good reference?
doc figure
Then you can click on the link with 'figure properties'.
alpedhuez you have asked 220 questions in total and I'm really surprised that you are still asking the basic questions ?

Sign in to comment.

Answers (1)

Vishal Gaur
Vishal Gaur on 9 Jun 2020
Edited: Vishal Gaur on 19 Jun 2020
You can add a title with variable in following way:
Suppose you want title like this: Figure 1: Sample Plot
figNo = 1;
figName = 'Sample Plot';
title(['Figure ' num2str(figNo) ': ' figName])
For more information, you can refer this documentation:

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Release

R2020a

Tags

Asked:

on 8 Jun 2020

Commented:

on 19 Jun 2020

Community Treasure Hunt

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

Start Hunting!