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

    %% Format Columns of Values from Arrays
% Format values taken from numeric arrays. Since the numeric arrays have
% multiple rows, |compose| returns a string array with the same number of
% rows.
X = [1 2 3 4 5]';
Y = X.^2;

%%
formatSpec = string('%d.^2 = %d');
str = compose(formatSpec,X,Y)