MATLAB Answers

Plotting multiple row as diffferent series from 1 table

17 views (last 30 days)
photoinduced
photoinduced on 26 Oct 2017
Commented: dpb on 26 Oct 2017
Hello,
I have a data table 63x9. in it i have 3 relevant colums for this plot i want to make. 1 is rdata.ID, rdata.timeX and rdata.CFUy. rdata.ID is an ID that goes from 1-8 of the 8 separate series i want to plot. the other 2 fields are of variable length but paired i.e. row 5 of both timeX and CFUy both have the same number of entires [x x x] but row 6 can have more or less.
I want to plot all points on a plot then extract the mean to make a line and show standard errors of each point. I am not sure how to make matlab plot the series separately by ID, do i need a for loop to look for only ID 1 and plot then move to ID 2 and plot? any examples on how that is done? thanks

  1 Comment

dpb
dpb on 26 Oct 2017
Sorry, I can't visualize the data from what you're describing... show us a sample instead of trying to only use words; we don't have the luxury of having your terminal in front of us for visual klews.
But, to plot multiple lines on a plot, there are two basic choices
  1. put the data in an array by column and plot will treat each column as a separate line for either a single X vector or X,Y arrays if independent variables are also different, or
  2. plot the first line then use hold on to add subsequent lines without losing first.
There are many variations on the above them, but that's the general idea. Look at "Getting Started" section on graphics in the documentation and the examples for the various; there are many to follow for the general idea.
A couple of general syntax notes as well--
  1. points to plot are easily selected by using indexing in arrays either as individual elements or columns/rows in conjunction with the colon as Y(:,3) is third column all elements (rows) or Y(:,idx) is the columns contained in (vector) variable idx,
  2. plot will treat in NaN values in an array silently by just not showing them so if you have fewer points in one versus another, augmenting that dataset with nan() values to the full size of the rest of the array will let you use the array syntax above...

Sign in to comment.

Answers (0)

Sign in to answer this question.

Tags