Page 1 of 2 12 LastLast
Results 1 to 15 of 16
Like Tree1Thanks

Math Help - Matlab weird help

  1. #1
    Newbie
    Joined
    Jun 2014
    From
    Zuzaru
    Posts
    8

    Matlab weird help

    ]As you can see in the photo, I have the values for A1..A7 and B1..B7.

    Then, I plot a graph for the upper side A1..A7 and fit an exponential to it in Matlab. The eq is y=22.297e^-5.323x

    After, I plot the graph for the lower side B1..B7 and fit an exponential to it. The eq is y=40.949e^-5.002x


    The problem is that it is needed the same value for e's exponent. So it is needed that for A and B I get maybe something like y=22.297 e^-5.4x for both curves.

    To do that I see that I can move the OX axis down/up and thus the y values for the A(x,y) and B(x,y) points change, making the equations for the curves change. But I want some kind of algorithm that can do this automatically until the exponents for e for both curves become as close as possible.



    How can I make Matlab

    1. fit the exponential curve for each graph (one for the As and one for the Bs)

    2. check the values for e's exponent for the curves that correspond to the two graphs

    3. find a value "d" to ad/subtract from the y values of the A(x, y) and B(x, y) so that now it has A(x, y+d) b(x, y+d)

    4. do 1 and 2 again and see if the values for e's exponent for both curves have become equal or at least as close as possible.

    5. show that value "d".


    Thank you!

    Matlab weird help-33333.jpg
    Last edited by isro1; June 20th 2014 at 10:34 PM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Junior Member
    Joined
    Jun 2014
    From
    Britain
    Posts
    27
    Thanks
    6

    Re: Matlab weird help

    Hi
    I was intrigued by your query.
    Your data appears to be the envelope for a decaying sinusiodal waveform.
    The y intercepts should be equal either side of zero ie y = +/-Vexp(-at)
    so V the amplitude and a the decay constant need to be numerically equal.
    If the sinusoid has a phase shift I don't think it will give you the necessary affect.
    Cheers
    Thanks from topsquark
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jun 2014
    From
    Zuzaru
    Posts
    8

    Re: Matlab weird help

    Hello,


    Thanks for your reply...

    My data is experimental and it is not exactly sinusoidal.

    Also, when I gather the data I choose where the OX is, I do not have any reference so it's my choice where Y is 0. So if I put OX too "up" or too "down" then the curve equations for up and down have different exponents for "e" which means the position I chose is not that good.

    That's why I need some sort of way to get those exponents as close to each other as possible for all my experimental trials.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Junior Member
    Joined
    Jun 2014
    From
    Britain
    Posts
    27
    Thanks
    6

    Re: Matlab weird help

    Hi

    Sorry I didn't catch on to what you were trying to do too well.

    If you take logs of each side you get a linear equation of the type ln(y) = ln(A) - kt where A is the max on the y axis and k is the parameter you want to match (I think ?).

    Would it help to combine the data (making the -ve values +ve) in this linear form and do a least squares fit.

    k would be a 'best fit' for your exponant and ln(A) a 'best fit' for your intercept on the y axis.

    Just a thought !

    Regards
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Jun 2014
    From
    Zuzaru
    Posts
    8

    Re: Matlab weird help

    Thank you! I will try to do that and see what happens. Sorry that I am replying so rarely, I am working on other things at the same time and then coming back to this. Thanks again for your replies!
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Jun 2014
    From
    Zuzaru
    Posts
    8

    Re: Matlab weird help

    Ok, so it is not working...

    I have another idea now... how about if I get the median or mode (most common) value for the graph and subtract/add that to the Y values?

    But I have an issue with this... The data I am creating the graph based on is not continuous. For example my data for X is 1 2 3 4 5 6 7 8 9 10 11 12 but for Y it's 5, 4, -2, -5, -4, -2, 2, 3, 2, 1, -1, -2 etc. In this case the mode I want would be 0, but the value 0 isn't in my data range. How exactly can I get excel or Matlab to generate a new data range that contains continuous data based on the graph it generated with the data given? I basically need continuous data that would generate the same graph line that excel/matlab generates using the points given.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Junior Member
    Joined
    Jun 2014
    From
    Britain
    Posts
    27
    Thanks
    6

    Re: Matlab weird help

    Hi isro1

    As you are still working on this problem it would help me to have a data set to try things out on.

    I am sure there is a way of handling these values to produce a suitable mathematical expression.

    Look forward hearing further from you.

    Regards
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Newbie
    Joined
    Feb 2015
    From
    Georgia
    Posts
    1

    Re: Matlab weird help

    You may ask those guys, i used this site once link
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Newbie
    Joined
    Jun 2014
    From
    Zuzaru
    Posts
    8

    Re: Matlab weird help

    hello,

    TF - I will check it out, thanks for the link!

    Guinster - You can see the data and some explanations in this excel file...thank you for trying to help!

    https://www.dropbox.com/s/rkorda1ie5...ple2.xlsx?dl=0
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Junior Member
    Joined
    Jun 2014
    From
    Britain
    Posts
    27
    Thanks
    6

    Re: Matlab weird help

    Hi Isro1

    Thanks for the data.

    Give me a couple of days to try some things and I will let you know what I come up with.

    Regards
    Follow Math Help Forum on Facebook and Google+

  11. #11
    Newbie
    Joined
    Jun 2014
    From
    Zuzaru
    Posts
    8

    Re: Matlab weird help

    Hey,

    Thank you for your help, I really appreciate it!

    Isro
    Follow Math Help Forum on Facebook and Google+

  12. #12
    Junior Member
    Joined
    Jun 2014
    From
    Britain
    Posts
    27
    Thanks
    6

    Re: Matlab weird help

    Hi isro1

    I have had a look at your data and have tried to fit an exponential decay to the envelope.

    You can see on the attachment a plot of the data where I have corrected the zero position on the y axis using the average of the values rather than the median.

    median = 1.5822 average = 1.7613

    The difference is insignificant compared to the asymmetry of the oscillations which is highlighted

    by the plot of y = 28e^(-1.9x)sin(31x-0.1) (in green).

    (a) the decay does not follow a simple exponential decay law and

    (b) the frequency of the oscillations is not constant.

    For these reasons I feel that it will not be possible to find a single exponential to model the peaks and the troughs simultaneously.

    Regards

    Matlab weird help-plot-data-model.png
    Follow Math Help Forum on Facebook and Google+

  13. #13
    Newbie
    Joined
    Jun 2014
    From
    Zuzaru
    Posts
    8

    Re: Matlab weird help

    Thank you for looking over the data! It is really great to get a second opinion on it!

    Do you think it would still be so asymmetric if we consider just the movement starting at peak 4 and ending at peak 8? The start point of the graph is so high in amplitude as the system was initially displaced manually, so maybe the first part should be ignored anyway...? What do you think?
    Follow Math Help Forum on Facebook and Google+

  14. #14
    Junior Member
    Joined
    Jun 2014
    From
    Britain
    Posts
    27
    Thanks
    6

    Re: Matlab weird help

    Hi isro1

    I am glad that you found my comments useful.

    I agree that the early oscillations should be ignored.

    Having skimmed through an old Physics text book on simple harmonic motion I read a comment on the simple pendulum ( a bob on a string ).

    'Mathematically the motion is only close to simple harmonic for small oscillations ie < 10 degrees.'

    I have fitted another damped sine wave on the attachement which seems to follow the data quite well for peaks 7,8,9 and 10.

    I think that your system might be settling down - the question then is can you measure the displacements with sufficient accuracy ?

    Regards
    Attached Thumbnails Attached Thumbnails Matlab weird help-damped-oscillations-2.png  
    Follow Math Help Forum on Facebook and Google+

  15. #15
    Newbie
    Joined
    Jun 2014
    From
    Zuzaru
    Posts
    8

    Re: Matlab weird help

    Hey,

    Thank you again for your input! That's the problem, that I am not sure what is sufficient accuracy for this experiment. it seems the damping is changing as the system slows down, hence the different curves that fit the experimental data at different times (different peaks)...

    I guess that for the centring I will just stick to using the average or the median in excel...

    Thanks again! Really appreciate it! It was really good to get another opinion on this.
    Follow Math Help Forum on Facebook and Google+

Page 1 of 2 12 LastLast

Similar Math Help Forum Discussions

  1. This is weird
    Posted in the LaTeX Help Forum
    Replies: 5
    Last Post: December 18th 2010, 10:52 AM
  2. Weird MCQ options!
    Posted in the Trigonometry Forum
    Replies: 4
    Last Post: February 5th 2010, 08:54 PM
  3. Weird sum problem
    Posted in the Calculus Forum
    Replies: 1
    Last Post: November 21st 2009, 03:47 AM
  4. weird one
    Posted in the Math Challenge Problems Forum
    Replies: 6
    Last Post: November 18th 2006, 05:43 PM

Search Tags


/mathhelpforum @mathhelpforum