Solved

How to Add same Index Array Elements in Octave

Posted on 2014-04-07
2
317 Views
Last Modified: 2014-04-08
I've generated elements w(i,j) of an array, most of which are zeros. Some of the elements have the same index j and I'd like to add them up and show each j with its corresponding summed up value. I tried v = sum(w) and it did show the summed up values but as elements of a large matrix, with most elements being zero. Is there a different way to accomplish that task?
0
Comment
Question by:judico
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Accepted Solution

by:
judico earned 0 total points
ID: 39985106
This is one possible solution, although I was hoping that there might be a way to avoid looping:

for j = 1:arr_rows
if sum(w)'(j) != 0
[j, sum(w)'(j)]
endif
endfor
0
 

Author Closing Comment

by:judico
ID: 39986323
This is the best solution I could come up with so far. There are memory problems for large arrays. I may address these problems later.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
In this post we will learn different types of Android Layout and some basics of an Android App.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Starting up a Project

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question