www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/IncludeVariablesInGraphTitleExample.m

    %% Include Loop Variable Value in Graph Title
% Use a
% loop to create a figure containing four subplots. In each subplot, plot a
% sine wave with different frequencies based on the loop variable |k|. Add
% a title to each subplot that includes the value of |k|.

% Copyright 2015 The MathWorks, Inc.


x = linspace(0,10,100);
for k = 1:4
    subplot(2,2,k);
    yk = sin(k*x);
    plot(x,yk)
    title(['y = sin(' num2str(k) 'x)'])
end