Repeat all operations for n rows inside an array (with n unknown)

Hi everybody,
i have an array like this (with unknown rows number):
0.3 0.4 4
0.5 0.6 3.1
and i'd like to repeat different operations for every rows to obtain different results for different row.
Thank you!

 採用された回答

Jan
Jan 2019 年 1 月 22 日
編集済み: Jan 2019 年 1 月 22 日

1 投票

M = [0.3 0.4 4; ...
0.5 0.6 3.1];
nRow = size(M, 1);
for iRow = 1:nRow
yourOperation(M(iRopw, :)) ...
end
If you want to collect the results, use either a matrix again:
result(iRow, :) = ...
Or if the output has different sizes or classes, use a cell array:
Result = cell(1, nRow);
for iRow = 1:nRow
Result{iRow} = yourOperation(M(iRopw, :)) ...
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

リリース

R2018b

タグ

質問済み:

2019 年 1 月 22 日

編集済み:

Jan
2019 年 1 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by