Search code examples
stringmatlabconcatenationmatlab-figurestring-concatenation

Concatenating strings while using figure command (MATLAB)


I'm trying to concatenate strings , when I concatenate them separately like this:

strcat({'Plot of f with a plot of iterates for c='},{int2str(c)})

no error comes.

But when I try to use them in figure command like this:

 figure('Name',strcat({'Plot of f with a plot of iterates for c='},{int2str(c)}))

I receive this error:

Error using figure
Value must be a string

Any reason for this?


Solution

  • as pointed out by @Matthias W. the output of strcat({'Plot of f with a plot of iterates for c='},{int2str(c)}) is a 1x1 cell, not a string as expected by figure() function.

    Try the following

    figure('Name',['Plot of f with a plot of iterates for c=', int2str(c)])