MATLAB: How to display a character string array next to a data array

concatenationdataMATLABstrings

Hello, I am a Matlab noob and I need some help. I wrote this function below to add a random offest to a row vector from -L:L. I had to evaluate this value in several different functions and present the data from each function next to the name of the function. So I made a string containing the names of the functions, but I don't know how present the data next to the function name. Sorry if this doesn't make much sense, but here is my code:
function F = hw5(L) intval = [-L:L] for k = 1:(2*L+1) offset = rand-0.5; val(k) = intval(k) + offset; end offset = val – intval val
x1 = floor(val); x2 = ceil(val); x3 = fix(val); x4 = round(val); x5 = int32(val); x6 = uint32(val); x7 = single(val); x8 = sin(val);
b = ['Floor ',; 'Ceil ',; 'Fix ',; 'Round ',; 'Int32 ',; 'Uint32 ',; 'Single ',; 'Sin ',];
a = [x1 , x2 , x3 , x4 , x5 , x6 , x7 , x8 ];
end

Best Answer

doc num2str
doc sprintf
etc., ...
One way...
>> b = {'Floor '; 'Ceil '}; % use a cell array for convenience in defining
>> x=rand(2,1); % some numeric values to associate with...
Now make a cell array suitable for framing...
>> cellstr([char(b) num2str(x,3)])
ans =
'Floor 0.815'
'Ceil 0.906'
>>