How to change a given name

5 vues (au cours des 30 derniers jours)
Dion Theunissen
Dion Theunissen le 9 Fév 2021
Commenté : Stephen23 le 9 Fév 2021
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';

Réponse acceptée

KSSV
KSSV le 9 Fév 2021
Modifié(e) : KSSV le 9 Fév 2021
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'

Plus de réponses (1)

Jan
Jan le 9 Fév 2021
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 commentaire
Stephen23
Stephen23 le 9 Fév 2021
+1 sprintf is the way to go.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by