How do I combine strings using strjoin without spaces being introduced?
Afficher commentaires plus anciens
Hi,
I am currently trying to run a code that goes through several folders of data. I am having a problem with the function strjoin.
I create a string array named conds, and I want to combine it with another string to get a directory. How can I get rid of this space? I do not want to use strrep to remove the spaces, because later on in my code I have a lot of spaces that I don't want deleted.
conditions = ["C1","C2","G1","G2","I-1","I-2","II-1","II-2","III-1","III-2","N1","N2","P1","P2"];
area = '02_Mapping_Small_Area';
for k = 1:length(conditions)
device = conditions(k);
Home = strjoin(['C:\Users\Me\Desktop\03_Figures\',device]) %Save location
Start=['C:\Users\me\Desktop\',area] %Data retrieval location
% Home = strrep(Home,' ','');
end
>>> Home = "C:\Users\me\Desktop\03_Figures\ C1"
>>> Start = 'C:\Users\me\Desktop\02_Mapping_Small_Area'
The space before C1 that occurs in Home is what I want to get rid of. I guess it has something to do with single and double quotations.
Thanks!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!