The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: maximum non-zero column index
Replies: 4   Last Post: Mar 4, 2010 3:14 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Claudio Pedrazzi

Posts: 26
Registered: 8/27/09
maximum non-zero column index
Posted: Mar 3, 2010 11:53 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello everyone,
I don't find a "vector" way to solve the following problem:

given a matrix R, find the highest column index containing a non-zero value. here is my algorithmic solution

function j_max=search_max_non_zero_index(R)
% Searches the maximum column index containing a non null value and returns it

for i=1:size(R,1)
for j=1:size(R,2)
if R(i,j)~= 0

I am almost sure that with a good usage of the "any" fuction, some of those loops can be eliminated.

Thanks for any help!
Best regards

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.