cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Ignore Zero / Blanks from Excel

ptc-5469450
1-Visitor

Ignore Zero / Blanks from Excel

I am using the insert excel component to input data. The data consist of columns with sparatic values in columns C-I. Columns A&B are completely full. I want to graph the sparitic values in C-I against col A. When the data is imported, all of the blank cell come in as zero. when plotting they also plot as zero. I want the plot to connect each value ignoring the zero's that were brought in.

Any ideas?

thanks

Ron

17 REPLIES 17

Could you please provide a typical data set?

Surmising that you have similar data, maybe something like this would work.

Clipboard01.jpg

Data set looks like this about 350 rows

P1c.JPG

Can you please upload the actual data set.

Werner_E
25-Diamond I
(To:ptc-5469450)

Is there any specific reason for using the Excel component?

I would rather use the READEXCEL function. Empty cells are replaced by NaN (Not-a-Number) by default or anything else you like. If used in a 2D NaN disconnects the graph. If this is not what you want, you can use the filterNaN() function to delete all rows in the matrix which contain at least one NaN.

09.06.png

P.S.: If asking a question here please always state which version of the program you are using. The screenshot you provided looks like you are using Prime, not real Mathcad. The solution given here will work there as well.

If you are sure that 0 is no valid data you can follow Mike's idea and filter out all rows which contain a zero, but you will have to delete the same rows in column A as well to be able to produce a valid plot. You may use augment(A,datacolumn) and combine match() and trim() to do so.

If this is not what you want, you can use the filterNaN() function to delete all rows in the matrix which contain at least one NaN.

I don't think that is an option because of his sporadic zero values.

Mike Armstrong wrote:

If this is not what you want, you can use the filterNaN() function to delete all rows in the matrix which contain at least one NaN.

I don't think that is an option because of his sporadic zero values.

It sure IS an option as those values will not be zero but NaN if he uses READEXCEL instead of the Excel component.

The real problem is that the component replaces emtpty cells by zero and we have no way to change that behaviour. Given the screenshot which was provided your appraoch can be an option as it seems that no valid data will be zero. Column A has to be treated the same so we probably get 7 different columns A for the abscisa.

Werner Exinger wrote:

Mike Armstrong wrote:

If this is not what you want, you can use the filterNaN() function to delete all rows in the matrix which contain at least one NaN.

I don't think that is an option because of his sporadic zero values.

It sure IS an option as those values will not be zero but NaN if he uses READEXCEL instead of the Excel component.

I do agree that he should use READEXCEL if possible.

Given the screenshot which was provided your appraoch can be an option as it seems that no valid data will be zero. Column A has to be treated the same so we probably get 7 different columns A for the abscisa.

A small program would achieve this. Although I think his graphs will look messy.

I am very new to mathcad you answer quicker than I can provide data

I am using PRIME 3

Attached is the data I am working with... I have not tried the READEXCEL yet will work on that. If it will plot the points I then want to use the curve fitting functions to produce a curve for the points.

thanks for the quick replys...

Ron

Have a look if the attached helps. I have used Werners suggested method. It needs advancing but will be a good start.

So if you follow my suggestion, I will follow yours and filter the zeros

I still don't like the Excel component but other than in Mathcad it seems to be the only possible way in Prime to embed the data in a convenient way to make the sheet self contained.

The attached should do the job, just do for the other columns what I did for P1.

@Mike: Something seems to be wrong with the data you used - the abscissa values seem to be wrong.

EDIT: No, your data is correct. The discrepancy is because Ron just exported the first 99 rows of his data.

09.06.png

Great! Both of these solutions are very helpful... learning but making some progress! Thanks for both of your inputs!!

Ron

Ron May wrote:

Great! Both of these solutions are very helpful... learning but making some progress! Thanks for both of your inputs!!

Ron

You are wecome. Hope the attached files from myself and Werner yield you what you want.

Werner_E
25-Diamond I
(To:ptc-5469450)

You are welcome!

There can arise a problem with both methods, though.

If one of the data columns does not contain any zero (or NaN), the functions match() (or filterNaN()) will fail. To be on the safe side you can use the try..onerror construct:

1.png

You can do likewise with the filterNaN() approach.

And while you are at it you may also write a small routine to make the filtering of several columns more convenient:

2.png

Find attached also a way to make the number of the last row to extract easily selectable (here: n) without the need to change all the output "Excel's" if you want to stay with the component.

3.png

Oh good. Thought I had made a mistake by rushing. 🙂

Announcements

Top Tags