Problem with concatenation, help me
Mostra commenti meno recenti
Hello people, I have a problem: I'm trying to cocatenate the following
arquivo = [arquivo int2str(x) '.FIL']
But when i see the content from "arquivo", we have "CUNOV000.FIL1.FIL" I dont want this ".FIL1", only the ".FILL". after "CUNOV000"
8 Commenti
Paolo
il 22 Mag 2018
Could you please post a snippet of code?
Daniel Fonsêca
il 22 Mag 2018
Modificato: Geoff Hayes
il 22 Mag 2018
Walter Roberson
il 22 Mag 2018
If you do not want the .FIL1 then why do you have the int2str() as apart of what you are adding on?
John BG
il 22 Mag 2018
Hi Daniel
I bet the contents of arquivo already contains the file extension, so you may not be removing the file extension before plugging all strings together.
Daniel Fonsêca
il 22 Mag 2018
Daniel Fonsêca
il 22 Mag 2018
Modificato: Walter Roberson
il 22 Mag 2018
Daniel Fonsêca
il 22 Mag 2018
Risposte (1)
[~,arquivo] = fileparts(arquivo);
arquivo = sprintf('%s%d.FIL',arquivo,x)
But there is no point in calling fileparts repeatedly in a loop:
[~,fnm] = fileparts(arquivo);
for k = 0:qarq
tmp = sprintf('%s%d.FIL',fnm,k);
[fid,msg] = fopen(tmp,'rt');
assert(fid>=3,msg)
...
fclose(fid);
end
Categorie
Scopri di più su Scope Variables and Generate Names in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!