Creating a series of x-y plots
Show older comments
Hey, I want to make a set of x-y plots based on data with the following format:
"Tag Property-A Property-B
X1 A11 B11
X1 A12 B12
...........................
X2 A21 B21
..........................."
Properties A and B are the x and y variables. Each tag is matched with several pairs of A and B, and each plot should include data with a specific tag. Since there are a good many tags, it is impossible to manually separate the data. So is there any commands in Matlab that can be used to create such plots? I hope I have clearly stated my question. Thanks. Lin
P.S. I just realized the format couldn't display properly, so I'll briefly describe the data: there are three columns of data: Tag, Property A, Property B. Each tag encompasses a certain amount of x-y pairs, and the purpose is to make every one of the tags a plot showing the scattered x-y relationship.
A sample data file is attached.
4 Comments
Chad Greene
on 29 Sep 2014
Can you give an example of your data, so we can have some numbers and strings to play with?
Lin
on 29 Sep 2014
Image Analyst
on 29 Sep 2014
I fixed the formatting for you, but please read this http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Lin
on 29 Sep 2014
Accepted Answer
More Answers (1)
Image Analyst
on 29 Sep 2014
Just use readtable
t = readtable(xlsFullFileName);
Then extract the columns, use unique() to find unique tag names, then use logical indexing in a loop to extract rows for each tag in turn and plot. Let us know if you can't figure it out. Sorry, but I have to run off somewhere now.
5 Comments
Chad Greene
on 29 Sep 2014
Just a note, I think readtable requires version 2013b or later.
Lin
on 29 Sep 2014
Image Analyst
on 30 Sep 2014
If you have tags, like "X1", "X2", "ABC", "This stuff", "Tag 42", whatever, and some of them occur just once, and some of them multiple times, you can get a list of all the names, just listed once, with the unique() function.
uniqueNames = unique(tagList);
Once you have that you can get a list of all rows that have a particular tag, say "X1", like rows 1, 2, 14, 33, and 73 have tag "X1". Then you can get columns 2 and 3 for just those rows and do whatever you want with them.
Lin
on 3 Oct 2014
Image Analyst
on 3 Oct 2014
Use ismember().
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!