Find Data in Table

5 Ansichten (letzte 30 Tage)
Roger Cox
Roger Cox am 2 Mai 2017
Kommentiert: dpb am 18 Mai 2017

I have some data that includes both numbers and text. The text is inconsistent in which column the information is in. Is it possible to sort this table in some way please?

Here is some example data. How for example would I plot the Speed & Time of Apples and of Oranges please?

----------------------------------------

ID / Speed / Time / Fruit 1 / Fruit 2 / Fruit 3

----------------------------------------

1 3 9 Apple Jam Cake

2 6 5 Cake Orange Jam

3 3 4 Jam Cake Apple

4 5 2 Jam Orange Cake

5 9 4 Jam Jam Orange

6 5 3 Pear Jam Cake

7 3 5 Cake Cake Cake

8 2 3 Jam Cake Apple

9 5 3 Jam Orange Jam

10 7 9 Jam Jam Apple

  22 Kommentare
Roger Cox
Roger Cox am 18 Mai 2017
I'm interested in Condition Based Maitenance. This could increase the capacity factor achieved for a constant ammount of maintenance work.
As you suggest, energy storage is another interesting area.
dpb
dpb am 18 Mai 2017
Interesting...spent last 10 or so year of employment career with CSI (Computational Systems, Inc.)for whom predictive maintenance is core business...they were just sold to Emerson Electric when I left to return to family farm; they now are pretty-much folded into Emerson so don't show up as CSI externally any longer ... <Emerson-embeds-prediction-data> might lead to some useful white papers, etc., etc., etc., ... <machinery-health-management>
Last piece I worked on was the wireless accelerometer, an industry first at the time...

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

dpb
dpb am 3 Mai 2017
Using categorical for the string columns has some advantages. I fixed up your listing above to be able to read as a table via
> t=readtable('cox.dat');
>> whos t
Name Size Bytes Class Attributes
t 10x6 2848 table
>> t.Properties
ans =
Description: ''
VariableDescriptions: {}
VariableUnits: {}
DimensionNames: {'Row' 'Variable'}
UserData: []
RowNames: {}
VariableNames: {'ID' 'Speed' 'Time' 'Fruit1' 'Fruit2' 'Fruit3'}
>>
With that it's easy enough to write
>> ix=any(ismember(t{:,4:6},{'Apple';'Orange'}),2); % find any row with apple or orange
>> t(ix,:) % display those found
ans =
ID Speed Time Fruit1 Fruit2 Fruit3
__ _____ ____ ______ ______ ______
1 3 9 Apple Jam Cake
2 6 5 Cake Orange Jam
3 3 4 Jam Cake Apple
4 5 2 Jam Orange Cake
5 9 4 Jam Jam Orange
8 2 3 Jam Cake Apple
9 5 3 Jam Orange Jam
10 7 9 Jam Jam Apple
>>
Use the logical index vector to access any other variable of interest.
It would be better going forward, of course, to normalize the database to put the three disparate properties in their own variable.
  5 Kommentare
Peter Perkins
Peter Perkins am 8 Mai 2017
When accessing one variable at a time, Obi Wan might also suggest using the dot:
plot(TT3.Speed(OR),TT3.Time(OR),'o',TT3.Speed(AP),TT3.Time(AP),'o')
But even with curlies, names are nice:
plot(TT3{OR,'Speed'},TT3{OR,'Time'},'o',TT3{AP,'Speed'},TT3{AP,'Speed'},'o')
dpb
dpb am 9 Mai 2017
Ever so, may be it can... :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by