Variable in title is appearing as random string characters.

2 visualizzazioni (ultimi 30 giorni)
Running matlab R2019a
Im creating a mesh plot.
Here is my code for the title:
og_rows = 15360
og_cols = 1024
title(['Form Removed Data ',og_rows, 'x', og_cols])
This is following the matlab guidelines here: https://uk.mathworks.com/help/matlab/ref/title.html
This strangely results in this:

Risposta accettata

Joe Pashley
Joe Pashley il 4 Set 2019
To use the format matlab reccomends, you must remember to change the number into a string. So the code would be:
title(['Form Removed Data ',num2str(og_rows), 'x', num2str(og_cols)])

Più risposte (2)

Walter Roberson
Walter Roberson il 4 Set 2019
title( sprintf('Form Removed Data %d x %d',og_rows, og_cols) )
  1 Commento
Joe Pashley
Joe Pashley il 4 Set 2019
Modificato: Joe Pashley il 4 Set 2019
Hey, thanks for your help.
I actually spotted my own mistake, it must be input as a string and not a number. But thanks for your answer anyway.

Accedi per commentare.


Steven Lord
Steven Lord il 4 Set 2019
Another option (instead of str2num or sprintf) is to use string operations.
og_rows = 15360;
og_cols = 1024;
title("Form Removed Data " + og_rows + " x " + og_cols)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by