How to Add Titles to Figures in Matlab Loops (M = 0.85:1:2.85)

  • Context: MATLAB 
  • Thread starter Thread starter ADunn
  • Start date Start date
  • Tags Tags
    Figure Matlab
Click For Summary

Discussion Overview

The discussion revolves around how to add titles to figures generated in a Matlab for loop, specifically for a range of values defined by M = 0.85:1:2.85. The focus is on coding techniques within the context of programming and data visualization.

Discussion Character

  • Technical explanation

Main Points Raised

  • One participant asks how to set titles for each figure in a loop based on the variable M.
  • Another participant suggests using the title function with a specific syntax to format the title string, indicating the correct usage of num2str to convert M to a string.
  • A subsequent post corrects a minor syntax error in the title function provided earlier.

Areas of Agreement / Disagreement

There appears to be agreement on the method to set titles, with a minor correction made regarding syntax. No significant disagreement is noted.

Contextual Notes

The discussion does not address potential limitations or assumptions regarding the context in which the code is executed, such as the specific Matlab version or any dependencies on figure properties.

Who May Find This Useful

Individuals interested in Matlab programming, particularly those working with data visualization and figure management in loops.

ADunn
Messages
6
Reaction score
0
In Matlab I have a for loop that plots a figure in each loop. (M = 0.85:1:2.85)
I would like to put a title on the figure "M = 0.85" for the first plot, "M=1.85" for the second plot, and "M=2.85" for the third plot. Can anyone tell me how to do this?

Thank you!
 
Physics news on Phys.org
title(['M = ',num2str(M)'])
 
Sorry, got an extra quote mark in there.
title(['M = ',num2str(M)])
 
Thank you so much!
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K