Solved

How to Add same Index Array Elements in Octave

Posted on 2014-04-07
2
307 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Report events not being triggered 8 113
wordcount challenge 11 103
python sqlite question 11 46
How to write an English digest paper 6 20
Introduction This question got me thinking... (http://www.experts-exchange.com/questions/28707487/GLOBALS.html) Why shouldn't we use Globals? This is a simple question without a simple answer.  How do you explain these concepts to a programmer w…
This is an explanation of a simple data model to help parse a JSON feed
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

914 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

14 Experts available now in Live!

Get 1:1 Help Now