Counting by 10

16 次查看(过去 30 天)
Frandy
Frandy 2012-2-17
编辑: Matt J 2013-10-15
Hey I need some help creating a code that is able to read a string in a text file and pull every 10th,20th,30th,40th,and so on and so forth. So I am currently trying to use the size function but isn't quite working. Any suggestions?
  2 个评论
Image Analyst
Image Analyst 2012-2-17
Pull every 10th, 20th, 30th, or 40th WHAT? Character from that string? Integer from that line of text? Line of text from that file? Are you using textscan(), fgets(), fgetl() or something else?
Frandy
Frandy 2012-2-18
Sorry I'm new to this...Ok so the text file has about 200 trials with many data points, each trial resembles this:
Right
2.34
3.45
2.34
2.56
3.65
4.56
6.23
3.21
2.31
3.26
6.43
3.23
4.01
3.21
4.10
...
Also I am using fgetl to read the text file line by line

请先登录,再进行评论。

回答(1 个)

Jeff E
Jeff E 2012-2-17
blah = char(65:120)
tens = blah(10:10:end)
  2 个评论
Frandy
Frandy 2012-2-18
This doesn't quite work for the application I need it in...For example the text file I am using has data points under different labels such as A, B, C, or D with 200 hundred of each. So I want to get every 10th B in the text file.
Image Analyst
Image Analyst 2012-2-18
Were we supposed to know that???? Why haven't you given an example of what the lines of text look like in your file? Otherwise, if people even bother, you'll just get guesses like this. Have you considered using dlmread()?

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by