Search code examples
matlabplottitlefigure

Matlab function parameter includes h. I want plot title to include same h. How to do?


function parameter includes h(=10). I want plot title to include the same h. how to do?

function G=graphit(X,Y,ye,h)
plot(X,Y,'-'); 
grid
title([ 'Approximate and Exact Solution @h= .', num2str(h)])

Thanks. MM


Solution

  • You can use sprintf to create a formatted string

    title( sprintf( 'Approximate and Exact Solution. h = %.0f', h ) );