Removing strings or NaNs from data to be plotted

5 Ansichten (letzte 30 Tage)
Stephen Devlin
Stephen Devlin am 16 Sep. 2016
Kommentiert: dpb am 19 Sep. 2016
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 Kommentar
Stephen Devlin
Stephen Devlin am 16 Sep. 2016
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

dpb
dpb am 16 Sep. 2016
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 Kommentare
Stephen Devlin
Stephen Devlin am 19 Sep. 2016
Hi dpb, I will have a look at this today, thank you for your help.
dpb
dpb am 19 Sep. 2016
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...

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by