フィルターのクリア

How do I make a file name with combination of two strings ?

94 ビュー (過去 30 日間)
farzad
farzad 2018 年 1 月 10 日
回答済み: Jan 2018 年 2 月 10 日
Hi All
How do I make a file name with combination of two strings ? most of the examples I have seen are combination of a file and a number

採用された回答

Jan
Jan 2018 年 2 月 10 日
folder = 'D:\Temp';
str1 = 'aaa'
str2 = 'bbb'
% Alternatives:
name = [str1, str2]
name = strcat(str1, str2)
name = cat(2, str1, str2)
name = horzcat(str1, str2)
name = sprintf('%s%s', str1, str2) % See Stephen's solution
% Creates: C\Temp\aaa\bbb
fullname = fullfile(folder, str1, str2)

その他の回答 (1 件)

Stephen23
Stephen23 2018 年 2 月 4 日
編集済み: Jan 2018 年 2 月 10 日
Use sprintf and adjust the format string to suit:
S1 = 'hello';
S2 = 'world';
name = sprintf('%s%s.txt',S1,S2)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by