Find Data in Table

조회 수: 5 (최근 30일)
Roger Cox
Roger Cox 2017년 5월 2일
댓글: dpb 2017년 5월 18일

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
Roger Cox
Roger Cox 2017년 5월 18일
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 2017년 5월 18일
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...

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

채택된 답변

dpb
dpb 2017년 5월 3일
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
Peter Perkins
Peter Perkins 2017년 5월 8일
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 2017년 5월 9일
Ever so, may be it can... :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by