for loop to step through strings?

I have a file containing 16 different variables. Each variable contains a vector of values. These variables all have different character names with varying lengths. Fortunately they are organized alphabetically. ex:
Filename -----> bed
cdd
cgf
gerds
etc...
Is there a way to use a loop to step through each of these variables?
I tried converting the variable names to ascii then comparing number values (using a shift right logical to keep only the first value) but this did not work because they are all of different lengths. Also - the srl would not work because some of the variable names have the same first (sometimes second) letter, so I have to compare those as well.
I could write out the same code 16 times using each variable name instead, but I was hoping for something quicker.

3 件のコメント

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2015 年 6 月 10 日
Hi,
I don't quite understand the problem and your approach!
Why do you compare the first letters? Or converting them ascii or ...?! Cant you use strcmpi() to simply compare the variables with one another one by one?!
Heidi
Heidi 2015 年 6 月 10 日
I have a 'big' file that contains 16 'small' files lets say. I need to apply an algorithm to each of the small files, but they all have different names. These names are similar to my example, bed, cdd, cgf, gerds.... is there a way to use a for loop to run through each small file? Like a for loop that compares strings?
dpb
dpb 2015 年 6 月 10 日
I can't follow the structure entirely...how about a small sample file that shows the content and what you want done, specifically?

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2015 年 6 月 10 日

コメント済み:

dpb
2015 年 6 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by