フィルターのクリア

add the particular column in the for loop

2 ビュー (過去 30 日間)
singh
singh 2015 年 5 月 4 日
コメント済み: Nobel Mondal 2015 年 5 月 4 日
hello friends, i wish to sum the column of the array which are present in the for loop
suppose iteration 1 is running and i get a single column from the array
next iteration 2 i get another column from array and add both column and store at the place
in iteration 3 i get another column from array and add this column with previous resulted column(adding in iteration 2) and now store the result at same place where iteration 2 result was stored

回答 (2 件)

Jan
Jan 2015 年 5 月 4 日
What about:
data = rand(10, 10);
result = sum(data, 2);
This is the sum of the columns.
  1 件のコメント
Nobel Mondal
Nobel Mondal 2015 年 5 月 4 日
Yes, this is way more efficient.

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


Nobel Mondal
Nobel Mondal 2015 年 5 月 4 日
Are you looking for something like this?
dataMatrix = [1 2 3; 4 5 6; 7 8 9];
outPut = zeros(size(dataMatrix,2),1);
for i=1:size(dataMatrix,2)
outPut = outPut + dataMatrix(:,i);
end

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by