Removing strings or NaNs from data to be plotted

1 次查看(过去 30 天)
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 中查找有关 Graphics Object Programming 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by