Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:19:20+00:00 2026-06-03T13:19:20+00:00

In octave, is there a build in function for replacing Inf/NaN to 0 in

  • 0

In octave, is there a build in function for replacing Inf/NaN to 0 in a vector

For example

a = log10([30 40 0 60]) => [1.4771 1.6021 -Inf 1.7782]

I can use finite or find function to find the index/position of the valid values
but I don’t know how to copy the values correctly without writing a function.

finite(a) => [1 1 0 1]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:19:21+00:00Added an answer on June 3, 2026 at 1:19 pm
    >> a = log10([30 40 0 60])
    a =
          1.477    1.602    -Inf    1.778
    
    >> a(~isfinite(a))=0
    a =
          1.477    1.602    0       1.778
    

    does the trick, this uses logical indexing

    ~ is the NOT operator for boolean/logical values and isfinite(a) generates a logical vector, same size as a:

    >> ~isfinite(a)
    ans =
         0     0     1     0
    

    As you can see, this is used for the logical indexing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, !vim in iPython opens vim. Is there such a thing in Octave?
Is there a possibility to use Octave headless. Something like this octave < 5+4
I'm trying to use SWIG to create a Octave function. But even the most
I use Octave with gnuplot under Windows. I can zoom in using the right
Is there a built-in function in Octave to crop a specific region from an
I often use Octave to create data that I can plot from my lab
Is there an Emacs major mode for MATLAB and / or Octave files? For
Is there a way to perform row wise operations on matrices in octave ?
I have a program in Octave that has a loop - running a function
I have a failure in some inner library function in Octave. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.