how do we get last two number from the string?
9 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Walter Roberson
2016-5-18
last4 = cellfun(@(S) S(end-3:end), {sublist.name}, 'Uniform', 0);
2 个评论
Walter Roberson
2016-5-19
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);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!