## So I have another matlab problem...

Should be a simple one, just can't get it to work. Basically, I have two sets of data that I want to compare. One set of data was observed at set intervals of time, and the second set of data is calculated - the problem is that the theoretical data has entries for non-integer values of t - when the observed is in single integer steps.

This means that for the period of a minute in the theoretical data, I'll have several values but only a single observed value. Unfortunately, the number of theoretical values in a given range differs throughout so I feel that the best way to sort this out would be to lose a bit of accuracy and plot the observed data then somehow automatically calculate a point for each bit in time which would correspond to my theoretical. Is this possible?
 Recognitions: Gold Member Science Advisor Plot both data sets and compare them or alternatively using the theoretical model, calculate the values given the experimental t's then plot and compare.
 I would calculate the experimental t's, but the theoretical data is calculated in an ODE solver with a defined tolerance (as far as I know, theres no way to define a definite step in ODE solvers, only an initial suggestion?). Leaves me with plotting the two results, is there any way to subtract two plots? Just to give a nicer comparison.

Recognitions:
Gold Member

## So I have another matlab problem...

Take the experimental output and the theoretical output and do a term by term search for the coincident times and subtract them.

I'd just plot both then make the comparision, it'd look better to me and more professional.
 If you're using Matlab's ODE solver you can give it the time values at which you want the solution. Also, you can use the interp functions to interpolate your solution down to the coarser time grid.

Recognitions:
Gold Member
 Quote by LeBrad If you're using Matlab's ODE solver you can give it the time values at which you want the solution. Also, you can use the interp functions to interpolate your solution down to the coarser time grid.

 Quote by Dr Transport Take the experimental output and the theoretical output and do a term by term search for the coincident times and subtract them. I'd just plot both then make the comparision, it'd look better to me and more professional.

 Quote by LeBrad If you're using Matlab's ODE solver you can give it the time values at which you want the solution. Also, you can use the interp functions to interpolate your solution down to the coarser time grid.
How do I force the ODE solver to take specific time values? Will that affect the accuracy of the solutions it finds at those points? As far as I knew (this is the first time I've used multiple ODE solvers in matlab) all I can do is give the solver an initial step suggestion and let it work through relative/absolute error tolerances to find the rest. thanks also, many a-far-more knowledgeable than I.
 It seems to me a bit dangerous interpolating the experimental data -- eg. the theoretical data could show much higher frequency dynamics than the experimental data. In which case, I would average out the theoretical data according to the time scale of the device used to measure the experimental stuff.

 Quote by fasterthanjoao How do I force the ODE solver to take specific time values? Will that affect the accuracy of the solutions it finds at those points? As far as I knew (this is the first time I've used multiple ODE solvers in matlab) all I can do is give the solver an initial step suggestion and let it work through relative/absolute error tolerances to find the rest. thanks also, many a-far-more knowledgeable than I.
If tspan is the time input argument to the ode solver, before you had
tspan = [t0, tf]
where t0 is the starting time and tf is the final time, just change it to
tspan = [t0, t1, t2, t3, t4, tf]
where t0,t1,t2,... are the points you want the solution at. And no, it does not affect the accuracy of the integration scheme, the ode solver solves it at many more points but only returns values for the specified points.

 Quote by J77 It seems to me a bit dangerous interpolating the experimental data -- eg. the theoretical data could show much higher frequency dynamics than the experimental data. In which case, I would average out the theoretical data according to the time scale of the device used to measure the experimental stuff.
This is what I meant by interpolate down to the coarser time scale.