www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/FormatValuesWithExtraOrMissingOperatorsExample.m
%% Format Values with Extra or Missing Operators % Format values when the number of columns in the data array is not equal % to the number of operators. If |A| has more columns, then |compose| % repeats |formatSpec| as an additional column of the output string array. formatSpec = string('The time is %d:%d'); A = [8 15 9 30; 10 20 11 50]; str = compose(formatSpec,A) %% % Format values when |A| has fewer columns. formatSpec = string('Check-in time %d:%d; Check-out time %d:%d'); A = [12 27; 11 16]; str = compose(formatSpec,A) %% % Since |A| has only two columns, |compose| uses only the first two % formatting operators in |formatSpec| to format the values. % |compose| leaves the other formatting operators unchanged.