I used to have a charachter vector like:
bound = ['c', 'f', 'f', 'f'];
And I got:
bound(1) = 'c'
bound(2) = 'f'
but then I needed to change it and have right now:
bound = ['ctb', 'f', 'f', 'f'];
but if I want to acces bound(1) I get just:
bound(1) = 'c'
But I need:
bound(1) = 'ctb'
So I thought i can use cells instead of char so i changed my code:
bound = {'ctb', 'f', 'f', 'f'};
And I get also
bound(1) = 'ctb'
But this is no more a character vector and I can't use it with mkdir to create folders. If you convert
char(bound)
you get an character array instead of a character vector. Also
strcat(bound)
remains a cell array. So how can I use mkdir with cell arrays or convert cell arrays to character vectors?
Just for clarification I use it late like this where numa, tnm, lxnum, npnum, stiffnum are integers and method is also a character vector:
nameap = [num2str(numa),'-',num2str(tnm), ...
'-',num2str(lxnum),'-',num2str(npnum), ...
'-',num2str(stiffnum),'-',strcat(bound),'-',method]; %Appendix of folders and files
simfol = ['sim-',nameap]; %simulation folder name
mkdir(char(simfol)); %Create folder for the simulation
Ans I use R2016b.

 Réponse acceptée

Adam Danz
Adam Danz le 16 Juil 2018
Modifié(e) : Adam Danz le 16 Juil 2018
bound = {'ctb', 'f', 'f', 'f'};
bound(1) % {'ctb'}, cell
bound{1} % 'ctb', char
bound{1}(1) % 'c', char

2 commentaires

so to get a character vector I should use
boundchar = [bound{1},bound{2},bound{3},bound{4}];
It functions but there doesen't exist a more elegant way?
Adam Danz
Adam Danz le 16 Juil 2018
Modifié(e) : Adam Danz le 16 Juil 2018
This produces the same results as your line above (but is much more efficient and it's what you're looking for).
boundchar = [bound{:}]

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange

Produits

Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by