フィルターのクリア

Combining if and for loop to iterate through a cell array

3 ビュー (過去 30 日間)
Jay Vankawala
Jay Vankawala 2020 年 3 月 6 日
コメント済み: Stephen23 2020 年 3 月 7 日
Pseudocode: I want to read column 2 of a cell array. If the value of column 2 is "x", then I want to open the matrix in column 1 of that same row (and do further code with that).
How should I construct this code? something like
for trialnumber = 1 : length(cellfilename)
if cellfilename (trialnumber, 2) == 'x'
load (cellfilename (trialnumber, 1))
end
end
That's the general idea. Already, an error is that Undefined operator '==' for input arguments of type 'cell'. Please let me know how I can accomplish this! Thank you :)

採用された回答

Sindar
Sindar 2020 年 3 月 6 日
編集済み: Sindar 2020 年 3 月 6 日
to access the contents of a cell array, use {} instead of ():
for trialnumber = 1 : length(cellfilename)
if cellfilename{trialnumber, 2} == 'x'
load(cellfilename{trialnumber, 1})
end
end

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by