Effacer les filtres
Effacer les filtres

how do we get last two number from the string?

5 vues (au cours des 30 derniers jours)
sam moor
sam moor le 18 Mai 2016
Modifié(e) : sam moor le 19 Mai 2016
I have a struct as 'r_m3_1.00','r_m3_1.05'....which i created using fullfile command for the folders. Now I want to get only last 4 digit of each folder name (i.e 1.00, 1.05....) in a struct and store in a new matrix form. How do I get only last 4 digit of each folder of the struct below?

Réponses (1)

Walter Roberson
Walter Roberson le 18 Mai 2016
last4 = cellfun(@(S) S(end-3:end), {sublist.name}, 'Uniform', 0);
  2 commentaires
sam moor
sam moor le 18 Mai 2016
what does this S represent?
Walter Roberson
Walter Roberson le 19 Mai 2016
Same thing as it would mean in the below:
last4 = cellfun(@last4char, {sublist.name}, 'Uniform', 0);
function r = last4char(S)
R = S(end-3:end);

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by