processing multiple data in matlab at once

4 ビュー (過去 30 日間)
Ali
Ali 2012 年 10 月 1 日
Hi everybody,
I have loaded a set of 50 files into Matlab workspace. (from data1 to data50)
the size of each one is 721*176.
I want to extract only the first 144 lines of each data and store it in another one.
for example
newData1 = data1(1:144,:);
My question is: How can I do this using a loop to process all data at once?
Thank you very much.

回答 (2 件)

José-Luis
José-Luis 2012 年 10 月 1 日
編集済み: José-Luis 2012 年 10 月 1 日
You could try using a cell array instead:
your_data = cell(numFiles,1);
Populate it (ideally when you read them)
your_data(1) = {data1}; %etc;
And then trim it:
trimFun = @(x) x(1:144,:);
your_trimmed_data = cellfun(trimFun,your_data,'uniformoutput',false);

Walter Roberson
Walter Roberson 2012 年 10 月 1 日

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by