How to change a given name

조회 수: 3 (최근 30일)
Dion Theunissen
Dion Theunissen 2021년 2월 9일
댓글: Stephen23 2021년 2월 9일
Hi,
An easy question but I can not find the solution. I have a number which is changing but i want to change it by myself.
How can I use that one in my folder name like this:
Thanks in advance
%% test
num = '0000060'
folder = 'C:\Users\dit\Documents\MATLAB\RawData\'+ num +'.csv';

채택된 답변

KSSV
KSSV 2021년 2월 9일
편집: KSSV 2021년 2월 9일
Also read about strcat.
%% test
num = '0000060'
num = '0000060'
folder = ['C:\Users\dit\Documents\MATLAB\RawData\',num,'.csv']
folder = 'C:\Users\dit\Documents\MATLAB\RawData\0000060.csv'

추가 답변 (1개)

Jan
Jan 2021년 2월 9일
num = '0000060'
folder = ['C:\Users\dit\Documents\MATLAB\RawData\', num, '.csv'];
% Or with strings instead of char vectors:
folder = "C:\Users\dit\Documents\MATLAB\RawData\" + num + ".csv";
% Or:
num = 60
folder = fullfile('C:\Users\dit\Documents\MATLAB\RawData\', ...
sprintf('%07d.csv', num))
  댓글 수: 1
Stephen23
Stephen23 2021년 2월 9일
+1 sprintf is the way to go.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by