how do we get last two number from the string?

조회 수: 5 (최근 30일)
sam moor
sam moor 2016년 5월 18일
편집: sam moor 2016년 5월 19일
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?

답변 (1개)

Walter Roberson
Walter Roberson 2016년 5월 18일
last4 = cellfun(@(S) S(end-3:end), {sublist.name}, 'Uniform', 0);
  댓글 수: 2
sam moor
sam moor 2016년 5월 18일
what does this S represent?
Walter Roberson
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 CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by