How to get the length of the text elements in character array

4 ビュー (過去 30 日間)
Karthick Jonagadla
Karthick Jonagadla 2016 年 4 月 27 日
コメント済み: Karthick Jonagadla 2016 年 4 月 27 日
I have a character array with values
val =
HINDALCOJAN2016FUT
INFRATELJAN2016FUT
INFRATELJAN2016FUT
NMDCJAN2016FUT
NMDCJAN2016FUT
SBINJAN2016FUT
SBINJAN2016FUT
I want to get the length of the string of each element in the character array. I know how to get the length using the for loop. Is there any efficient method other than using for loop?
After knowing the length of each string, I need to extract strings from position 1 to length of each string minus 10

採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 4 月 27 日
f = fopen('20160427.txt');
c = textscan(f,'%s','delimiter','\n');
fclose(f);
out = cellfun(@(x)x(1:end-10),c{:},'un',0);
  1 件のコメント
Karthick Jonagadla
Karthick Jonagadla 2016 年 4 月 27 日
The solution worked. Thanks for the help :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by