Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is equivalent of Matlab nan( ) in python?

this is my MATLAB code with the following output:

pad=nan(1,5)

pad =

   NaN   NaN   NaN   NaN   NaN

I want to do the same operation in python, I tried np.isnan(1,6) but this is not working. what should I used to get the same results. thank you

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use np.full() to create a multi-dimensional array pre-populated with the same values:

np.full((1, 5), np.nan)

which produces:

array([[nan, nan, nan, nan, nan]])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading