Insert a string section on the numbers in a vector

1 次查看(过去 30 天)
A = [ 2 7 9 13];
add text CH_ on each value in the vector A
output
B = [CH_2 CH_7 CH_9 CH_13]

采纳的回答

Bhaskar R
Bhaskar R 2020-2-21
res = arrayfun(@(x)strcat('CH_', num2str(x)), A, 'UniformOutput', false);
res{1}, res{2} % to get each element

更多回答(1 个)

HERBERT NYAKOOJO
HERBERT NYAKOOJO 2020-2-21
A = [ 2 7 9 13];
str = sprintf('CH_%d ',A);
CH_2 CH_7 CH_9 CH_13

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by