필터 지우기
필터 지우기

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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by