Applying For Loop function to cell array

2 ビュー (過去 30 日間)
Dan Banbury
Dan Banbury 2017 年 3 月 13 日
コメント済み: Abhishek Baba 2020 年 11 月 24 日
I have a 1x48 cell array and want to apply the following code to every cell, how can i go about doing this?
zerIdx=[];
for i=3840:length(File name)-6398 %3840 is 30 sec and 16638 is 130 sec
if ((File name(i)>0 && File name(i+1)<0))
zerIdx(end+1)=i; % save index of zero-crossing
end
end
New Name=STime(zerIdx); % display timepoints of zero-crossings
mean(diff(New Name))
  3 件のコメント
Dan Banbury
Dan Banbury 2017 年 3 月 13 日
The intention is that the cells will be "file name". Then new name will be a different variable that is produced from that function.
Abhishek Baba
Abhishek Baba 2020 年 11 月 24 日
Hi Dan, it's kinda pretty late and a bit awkward too but did you get the answer to this thing?
I too am facing the same problem of applying 'for' loop in a cell. (I've applied a function to a subcell and I want to apply that same function to all the cells and subcells).
Any help will be much appreciated.
Thank you.

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

回答 (1 件)

Kushagr Gupta
Kushagr Gupta 2017 年 3 月 15 日
There are two ways to index into a cell array, using curly braces-{} and parentheses-().
Enclose indices in smooth parentheses, (), to refer to sets of cells--for example, to define a subset of the array. Enclose indices in curly braces, {}, to refer to the text, numbers, or other data within individual cells.
To read more about it, go through the documentation available at the " Access Data in Cell Array " link.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by