how to add the first row all the odd columns by step of 2 odd columns

3 ビュー (過去 30 日間)
juveria fatima
juveria fatima 2018 年 9 月 1 日
編集済み: Image Analyst 2018 年 9 月 1 日
I want to add 1 and 3 the 2 and 1. Then moving to second row I want to add 1 and 1 then 4 and 5. Similarly I want to, in general, using using loop for an image
a = [...
1 2 3 1
1 4 1 5
5 8 5 9
1 9 2 1]
  2 件のコメント
madhan ravi
madhan ravi 2018 年 9 月 1 日
What’s your required output ? Can you give an example?
juveria fatima
juveria fatima 2018 年 9 月 1 日
i want to add first column with third ,then fifth column to be added with seventh in short (i want to add all the odd columns) then even columns to added

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

採用された回答

madhan ravi
madhan ravi 2018 年 9 月 1 日
編集済み: madhan ravi 2018 年 9 月 1 日
Try this:
a1=a(:,1:2:end) %for odd columns
a2=a(:,2:2:end) %for even columns
oddcolumns=sum(a1,2)
evencolumns=sum(a2,2)
a
  15 件のコメント
madhan ravi
madhan ravi 2018 年 9 月 1 日
Check the updated code.
juveria fatima
juveria fatima 2018 年 9 月 1 日
consider this as encoding code where a is encoded as odd columns and even columns
a=[1 2 3 1;1 4 1 5;5 8 5 9;1 9 2 1]
a1=a(:,1:2:end) %for odd columns
a2=a(:,2:2:end) %for even columns
oddcolumns=sum(a1,2)
evencolumns=sum(a2,2)
now i want its inverse i.e decoding back to a ( output should be a )

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by