Removing strings or NaNs from data to be plotted

조회 수: 2 (최근 30일)
Stephen Devlin
Stephen Devlin 2016년 9월 16일
댓글: dpb 2016년 9월 19일
Hi, I have txt files which represent results of measurements of objects in flight and occasionally an object will not be present, as a feature this is of as much interest as the objects we get data for. So the txt file will show the missing objects with a string of letters, all other fields in the file being numbers (except for the headers). I have tried for days to replace the strings with an empty cell, in a cell array, but this cannot be plotted directly from the cell array. When i convert the Cellarray to doubles the blanks are filled by NaNs which I cannot plot either. I am sure I am missing something obvious but I have been reading all the documentation online and tried to tweak solutions to other peoples questions to no avail, I always end up with something that only does half the job I want. Any ideas?
Best regards
  댓글 수: 1
Stephen Devlin
Stephen Devlin 2016년 9월 16일
Hi, I was not asking for a "This question is: * Do it for me * Not likely to be useful to future visitors * Too open-ended", I was asking for general advice. I have converted my txt files into cells, structs,doubles and always there is some problem in one of the arrays that I can only solve in a different type of array. Specifically I wanted to know if there was a way to have a double array where blank/empty cells were preserved and later a plot of that data would show an empty space, from my reading of the documentation that is not possible as when the cell data is converted into a double array the double array is resized and the data is moved to fill any empty spaces, that is of no use to me in this instance. I have cells where the data is exactly how I want it, but I cannot plot it from the cell columns.

댓글을 달려면 로그인하십시오.

채택된 답변

dpb
dpb 2016년 9월 16일
Well, ideas would depend upon what you want -- plot and friends will gladly handle NaN; they even show where they are located if you use a line by making breaks at those points. If you were to want to make some different sort of mark at those locations, one option would be to first plot normally; then replace the NaN values with (say) an interpolated value and use scatter to add those as points to the preceding plot. Any number of alternatives could be imagined; just depends on what you're trying to accomplish.
  댓글 수: 4
Stephen Devlin
Stephen Devlin 2016년 9월 19일
Hi dpb, I will have a look at this today, thank you for your help.
dpb
dpb 2016년 9월 19일
Well, if you have "issues", supply more details of what the effect(s) you're trying to create are and undoubtedly others may well have better solutions. Oh, there's also always the File Exchange -- somebody else may have already built an enhanced mousetrap for the type of plot you're envisioning, particularly if it is a type commonly used in some area of data analysis/presentation...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by