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 8053071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:44:16+00:00 2026-06-05T07:44:16+00:00

In Mathematica, I have a matrix ‘a’ with missing values and I have a

  • 0

In Mathematica, I have a matrix ‘a’ with missing values and I have a matrix ‘b’ with same dimension as ‘a’. I would like to calculate a-b but if the value is missing, which I denote by ‘NA’, I would like it to remain as ‘NA’. Could you please help me with this? Please note that ‘a’ is of the dimension 1millionX300.

Thanks!

  • 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-05T07:44:17+00:00Added an answer on June 5, 2026 at 7:44 am

    One approach would be to use a replacement rule on the result, something like this;

    In[1]  {1, na, 3, na, 5} - {1, 2, 3, 4, 5}
    Out[1] {0, -2 + na, 0, -4 + na, 0}
    
    In[2]  {1, na, 3, na, 5} - {1, 2, 3, 4, 5}/. x_ + na -> na
    Out[2] {0, na, 0, na, 0}
    

    Another approach would be to define an UpValue for na such that addition (and subtraction) involving it would always result in na; like this:

    In[3] na /: Plus[___, na, ___] := na
    

    UpValues would be the way to go if you are going to do the operation more than once, replacement rules for a one-off.

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

Sidebar

Related Questions

I have a question about mathematica. I have an array with values called tempDep:
I have a big list of rules in Mathematica, but I want to select
I have an Expr object in C#, which represents Wolfram Mathematica 's type -
In Mathematica, do I have to use an explicit loop to calculate the product
Does mathematica have something like select any that gets any element of a list
I have a mathematica list in which I want to replace all 2s with
I have a list of lists (matrix) in mathematica. I want to print it
I have a mathematical matrix class. It contains a member function which is used
I have a problem which I try to solve with mathematica. I am having
I have a set of regular (mod 5) matrices N2 and I would like

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.