Cody

Solution 943369

Submitted on 26 Aug 2016 by J.R.! Menzinger
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
fmt='%.3f'; v=[-3.1416 -1.5708 0 1.5708 3.1416]; c_exp={ '-3.142' '-1.571' '0.000' '1.571' '3.142'}; assert(isequal(vector2formattedstringCA(fmt,v),c_exp))

y = '-3.142' '-1.571' '0.000' '1.571' '3.142'

2   Pass
fmt='%.6f'; v=rand(1,5); c_exp={}; for data=v c_exp{end+1} = sprintf(fmt,data); end assert(isequal(vector2formattedstringCA(fmt,v),c_exp))

y = '0.353854' '0.251324' '0.248023' '0.797806' '0.258685'

3   Pass
fmt='%i'; v=rand(1,10)*100; c_exp={}; for data=v c_exp{end+1} = sprintf(fmt,data); end assert(isequal(vector2formattedstringCA(fmt,v),c_exp))

y = Columns 1 through 5 '4.548188e+01' '5.359160e+01' '9.066427e+01' '2.055919e+01' '9.736689e+01' Columns 6 through 10 '4.642793e+01' '1.235940e+01' '4.945523e+01' '3.699317e-01' '8.922929e+00'