views:

80

answers:

1

Hey guys,

My question is to shorten repeating the process.

Data1=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[31 1 286 255]);

Data2=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[299 1 554 255]);

Data3=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[567 1 822 255]);

Data4=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[835 1 1090 255]);

Data5=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[1103 1 1358 255]);

Data6=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[1371 1 1626 255]);

Data7=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[1639 1 1894 255]);

Data8=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[1907 1 2162 255]);

Data9=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[2175 1 2430 255]);

Data10=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[2443 1 2698 255]);

Data11=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[2711 1 2966 255]);

Data12=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[2979 1 3234 255]);

Data13=dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t',[3247 1 3502 255]);

where the first 30 lines must be skipped before obtaining Data1. After Data1, 12 lines must be ignored for Data2 - Data13. Each data contains 256*255 matrix.

Note: dlmread('myfile.txt', '\t', [R1 C1 R2 C2]);

I would be really greatful for all your helps. Thank you.

+5  A: 

you could use a loop and collect your data sets in a cell array, something like (not tested)

nData = 13;

data = cell(nData,1);

for n = 1:nData
    startPos = 31+(n-1)*268;
    endPos = 286 + (n-1)*268;

    data{n} = dlmread('BadgCk-20001103-RZhS-1hAccumx10-TextData0-1.txt','\t', [startPos 1 endPos 255]);
end

edit: if you want combine all the data to one large matrix afterwards, you can use

dataMatrix = [data{:}]

you may need to transpose the result of dlmread first depending on how you want to concatenate into the final matrix

second
Thank you second.. It works just fine !!!
Nadhris
If you dont mind I would like to ask for one more thing. Say if your nData has a dimension of [1,65280]. How can I combine all of them into 1 large matrix in term of data{n}? For example, Data =[Data1;Data2;Data3;Data4;Data5;Data6;Data7;Data8;Data9;Data10;Data11;Data12;Data13];
Nadhris
added as edit to answer
second
What if I want to find the average of all the data:for example,Avg_data = (Data1+Data2+Data3+Data4+Data5+Data6+Data7+Data8+Data9+Data10+Data11+Data12+Data13)/13Thanks again..
Nadhris