how to read values from a file

Hi All I had a data containing lets say 3000 values I just want to read first 100 values from the data then next 100 values and then next 100 values and so on... Anyone plz help

7 件のコメント

Paolo
Paolo 2018 年 7 月 14 日
What format is your file? Is there a reason as to why you want to read data 100 values at a time rather than all at once?
John Hock
John Hock 2018 年 7 月 14 日
i loaded the file in the matlab i just want to process first 100 values then next 100 and so on its the requirement of my programme
Paolo
Paolo 2018 年 7 月 14 日
What sort of processing do you want to do? What data are you working with? Would be useful it you attached your file to the question.
John Hock
John Hock 2018 年 7 月 14 日
i had done all the rest work i am just facing the issue how to read 100 values and then next 100
dpb
dpb 2018 年 7 月 14 日
The point is there's no point... :)
Just operate on the subsets in memory or oftentimes if the data are divisible by the subset then one can use the vector nature of ML and do it all at once't...
x=1:100; x=x(:); % vector of 100 elements
>> mn=mean(reshape(x,25,[])).' % compute means groups of 25
mn =
13
38
63
88
>>
The point is don't throw out the possibility of better solution a priori...
John Hock
John Hock 2018 年 7 月 15 日
Thnx @dpb for your time My main question is that lets assume i have 20 values in my data set lets say (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)i just want to read first 5 values (i.e 1 2 3 4 5)then next 5 (6 7 8 9 10)and so on Will you please help me how i can do this
dpb
dpb 2018 年 7 月 15 日
編集済み: dpb 2018 年 7 月 16 日
This is akin to the problem of creating named sequential variables; not as problematic but still indicative of a non-optimal coding solution.
As you can tell, we're rather reluctant to lead folks down what may be non-productive paths, but if you're absolutely adamant and still won't share sufficient information to lead to a better solution, look at the optional 'N' arguments in functions like textread, fscanf.
You may also find while and feof of use...

回答 (0 件)

この質問は閉じられています。

製品

リリース

R2013a

タグ

質問済み:

2018 年 7 月 14 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by