# How to plot categorical data to compare with SimBiology simulation result?

1 view (last 30 days)

Show older comments

##### 6 Comments

Arthur Goldsipe
on 9 Mar 2022

Oh, first of all, apologies for posting an answer as a comment. I meant to post the above as an answer. But maybe that's irrelevant since I didn't understand your question correctly.

Sadly, I'm still a little unclear on exactly what you need help with. Could you provide sample data and/or code that illustrates the problem? Something like "Here's sample data. Here's the code I've written so far. And here's a sketch of what I'd like the plot to look like for this example." You've certainly described those things at a high level, but it's hard to know what to suggest without a bit more detail.

If you have concerns over sharing anything publicly here, please feel free to contact me directly, or perhaps you could contact Technical Support.

### Answers (1)

Arthur Goldsipe
on 11 Mar 2022

If I understand your question, you're primarily asking how to extract the simulation results at a specific time (for example, 5 days). It sounds like you already have the simulation results, which you obtained by calling sbiosimulate. I'm assuming your simulation time units are day. However, it's not clear to me whether you have those results as a SimData object or as numeric arrays. If you have the results in SimData you can estimate the results at 5 days using the resample method. If you have the results in numeric arrays, you can estimate the resutls at 5 days using the interp1 function. In both cases, I default to the pchip interpolation method. Here's some sample code.

t = 5;

% Case 1: SimData

simdata = sbiosimulate(model);

simdata1 = resample(simdata, t, 'pchip');

[~,x1] = getdata(simdata1);

% Case 2: Numeric arrays

[tManyTimes,xManyTimes] = sbiosimulate(model);

x2 = interp1(tManyTimes, xManyTimes, 5, 'pchip');

% Now plot the data

plot(t, x1, 'o')

plot(t, x2, 'o')

##### 0 Comments

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!