MATLAB So I have another matlab problem

  • Thread starter Thread starter fasterthanjoao
  • Start date Start date
  • Tags Tags
    Matlab
AI Thread Summary
The discussion revolves around comparing two sets of data: one observed at integer time intervals and another theoretical set calculated at non-integer values. The challenge lies in aligning these datasets for effective comparison. Suggestions include plotting both datasets together for visual comparison and using MATLAB's ODE solver to specify time points for theoretical data output. Interpolation functions can be employed to adjust the theoretical data to match the observed time scale. There are concerns about the accuracy of interpolating experimental data due to potential high-frequency dynamics in the theoretical model. A proposed solution is to average the theoretical data according to the measurement time scale of the experimental data to mitigate this issue. Overall, the focus is on achieving a clear and professional comparison between the two datasets while maintaining accuracy in representation.
fasterthanjoao
Messages
730
Reaction score
1
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?
 
Physics news on Phys.org
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, there's 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.
 
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.
 
LeBrad said:
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.


Very true...Forgot about those functions.
 
Dr Transport said:
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.

thanks, advice appreciated

LeBrad said:
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.
 
Last edited:
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.
 
fasterthanjoao said:
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.


J77 said:
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.
 
  • #10
excellent. Very much appreciated LeBrad.
 

Similar threads

Replies
1
Views
3K
Replies
12
Views
4K
Replies
12
Views
3K
Replies
3
Views
7K
Replies
2
Views
4K
Back
Top