So I have another matlab problem

  • Context: MATLAB 
  • Thread starter Thread starter fasterthanjoao
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary

Discussion Overview

The discussion revolves around a MATLAB problem involving the comparison of two data sets: one observed at integer time intervals and the other theoretical data calculated at non-integer time values. Participants explore methods for effectively plotting and comparing these data sets, considering the implications of interpolation and the use of ODE solvers.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant suggests plotting both data sets and comparing them directly or calculating theoretical values at the observed time points for comparison.
  • Another participant mentions the challenge of using an ODE solver, noting that it typically does not allow for fixed time steps but rather works with suggested initial steps and tolerances.
  • Some participants propose subtracting the two plots for a clearer comparison, while others emphasize the importance of matching time points for accurate analysis.
  • There is a suggestion to use MATLAB's interpolation functions to adjust the theoretical data to match the observed time intervals.
  • Concerns are raised about the potential dangers of interpolating experimental data, particularly if the theoretical data exhibits higher frequency dynamics than the experimental data.
  • A later reply discusses how to specify time values in the ODE solver without affecting the accuracy of the integration scheme, clarifying that the solver can return values for specified time points.
  • Another participant suggests averaging the theoretical data according to the time scale of the experimental measurements to mitigate issues with frequency dynamics.

Areas of Agreement / Disagreement

Participants express a variety of approaches to the problem, with no clear consensus on the best method for comparing the data sets. Some agree on the utility of plotting both sets, while others highlight the risks associated with interpolation and the need for careful consideration of time scales.

Contextual Notes

Participants note limitations regarding the assumptions made in using ODE solvers and the potential impact of interpolation on the accuracy of the results. The discussion reflects varying levels of familiarity with MATLAB and its functions.

Who May Find This Useful

This discussion may be useful for individuals working with MATLAB in the context of data analysis, particularly those dealing with experimental and theoretical data comparisons in physics or engineering.

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 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 12 ·
Replies
12
Views
4K
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
9K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K