Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab Spline Fit

  1. Dec 5, 2015 #1
    Hi Everyone

    I am Arman.I am at first grade in Physics and I have trouble to understand Matlab.Now we did Energy Conservation Experiment.I draw x-t and F-t graphs using matlab.Instructor told us we should use spline fit to draw a F-t graph.I dont have a toolbox about it.She told us some code like

    "hh=(xx,....)"

    It was something like this I dont remember exactly.How can I do that.I can send my graph codes If its necessery.

    Sincerely Arman
     
  2. jcsd
  3. Dec 5, 2015 #2

    DrClaude

    User Avatar

    Staff: Mentor

  4. Dec 5, 2015 #3
    Thank you. But I have some trouble again.
     

    Attached Files:

  5. Dec 5, 2015 #4

    DrClaude

    User Avatar

    Staff: Mentor

    You don't have the same number of values of x as you have of F.
     
  6. Dec 5, 2015 #5
    I have again problem.
     

    Attached Files:

    • 3.png
      3.png
      File size:
      75.3 KB
      Views:
      54
  7. Dec 5, 2015 #6

    DrClaude

    User Avatar

    Staff: Mentor

    Why are you trying to spline F with respect to x? In the OP, you say you are working with F vs t.
     
  8. Dec 5, 2015 #7
    I should draw Fx so so sorry
     
  9. Dec 5, 2015 #8
    My foolish mistake If you can help me I ll be glad.
     
  10. Dec 5, 2015 #9

    DrClaude

    User Avatar

    Staff: Mentor

    You mean that you plot force vs position, and you need to fit that curve? If that is the case, are all the values of x distinct?
     
  11. Dec 5, 2015 #10
    I have f-t and x-t grpahs and I want to make F-x.But When we want to make to grapsh together there will be a time difference.I mean lets suppose x-t graph is t=0.34 x=1.5 but in F-t graph t=0.35 F=1.5 so the time difference should be fixed and spline fit makes that thing I guess.
     
  12. Dec 5, 2015 #11
    .Basically I want to plot F-x Graph using F-t and x-t graph and spline fit
     
  13. Dec 5, 2015 #12
    If I cant I will gonna just take F and x and put them.Which not correct put Its fine enough ??
     
  14. Dec 5, 2015 #13

    DrClaude

    User Avatar

    Staff: Mentor

    Then what you want to do is to spline F at the same points in time as x.

    FF = spline(t,F,xx)
     
  15. Dec 5, 2015 #14
    It worked but graph is so nonsense.I dont know why ?
     
  16. Dec 5, 2015 #15
    what will be that plot code
    "yy = spline(x,y,xx);
    plot(x,y,'o',xx,yy)"

    Example in the Mathlab

    My idea
    FF = spline(t,F,xx)
    plot(t,F,'o',xx,FF)
     
  17. Dec 5, 2015 #16

    DrClaude

    User Avatar

    Staff: Mentor

    That will give you F vs t, not F vs x. Now that you have FF at the same points in time as x, you can plot
    plot(x,F)
     
  18. Dec 5, 2015 #17
    Theres one problem again
    1)I dont have 400 N but it still writes 400 N I dont know why ?

    By the way thanks
     

    Attached Files:

    • 4.png
      4.png
      File size:
      72.5 KB
      Views:
      73
    • 5.png
      5.png
      File size:
      66.2 KB
      Views:
      56
  19. Dec 5, 2015 #18

    DrClaude

    User Avatar

    Staff: Mentor

    Could you show the plot
    plot(t,F,'o',xx,FF)
     
  20. Dec 5, 2015 #19
    ok
     

    Attached Files:

  21. Dec 5, 2015 #20

    DrClaude

    User Avatar

    Staff: Mentor

    It doesn't work because you are extrapolating data outside the time range of the force measurements. I don't understand how come you have position data at such different times than force data.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Matlab Spline Fit
Loading...