Solved

How to Add same Index Array Elements in Octave

Posted on 2014-04-07
2
302 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
  • 2
2 Comments
 

Accepted Solution

by:
judico earned 0 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now