Matlab Spline Fit

  • MATLAB
  • Thread starter Arman777
  • Start date
  • #1
2,148
183
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
 

Answers and Replies

  • #3
2,148
183
Thank you. But I have some trouble again.
 

Attachments

  • Adsız.png
    Adsız.png
    75.8 KB · Views: 437
  • Adsız 1.png
    Adsız 1.png
    75 KB · Views: 481
  • #4
DrClaude
Mentor
7,627
4,068
You don't have the same number of values of x as you have of F.
 
  • #5
2,148
183
I have again problem.
 

Attachments

  • 3.png
    3.png
    75.3 KB · Views: 431
  • #6
DrClaude
Mentor
7,627
4,068
Why are you trying to spline F with respect to x? In the OP, you say you are working with F vs t.
 
  • #9
DrClaude
Mentor
7,627
4,068
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?
 
  • #10
2,148
183
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.
 
  • #11
2,148
183
.Basically I want to plot F-x Graph using F-t and x-t graph and spline fit
 
  • #12
2,148
183
If I cant I will gonna just take F and x and put them.Which not correct put Its fine enough ??
 
  • #13
DrClaude
Mentor
7,627
4,068
Then what you want to do is to spline F at the same points in time as x.

FF = spline(t,F,xx)
 
  • Like
Likes Arman777
  • #14
2,148
183
It worked but graph is so nonsense.I dont know why ?
 
  • #15
2,148
183
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)
 
  • #16
DrClaude
Mentor
7,627
4,068
plot(t,F,'o',xx,FF)
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)
 
  • Like
Likes Arman777
  • #17
2,148
183
Theres one problem again
1)I dont have 400 N but it still writes 400 N I dont know why ?

By the way thanks
 

Attachments

  • 4.png
    4.png
    72.5 KB · Views: 404
  • 5.png
    5.png
    66.2 KB · Views: 380
  • #18
DrClaude
Mentor
7,627
4,068
Could you show the plot
plot(t,F,'o',xx,FF)
 
  • #20
DrClaude
Mentor
7,627
4,068
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.
 
  • #21
2,148
183
Let me send my data graphs each of them.And Data.If you want you can look.
 

Attachments

  • Position-Time Part A.png
    Position-Time Part A.png
    72.2 KB · Views: 456
  • Force-Time Part A.png
    Force-Time Part A.png
    71.1 KB · Views: 453
  • expo 5 for force-time new.txt
    2.9 KB · Views: 377
  • expo5 part a position time new.txt
    3.2 KB · Views: 391
  • #22
2,148
183
>> t=position_time(:,1);
>> x=position_time(:,2);
>> t=force_time(:,1);
>> F=force_time(:,2);
>> tt=0.8:3.1;
>> tt=0.8:0.1:3.1
FF=spline(t,F,tt);
>> plot(x,F);

It worked I can send the image its consist with the result.Thank you
 
  • #23
2,148
183
Is it consist with the two graph that I send you ?
And I have a problem My graph says the work done is 0.26 J using trapz code.
I calculated the ΔKE=1/2mΔv2 Which gave me 0.42 J
and the real result using mgsinθx=W gave me 0.34 J

It means theoritaical value is 0.34 J , my experimental graph value is 0.26 J , experimental speed value is 0.42 J

There will be a friction and ΔKE-Wf=0.26J so 0.16 J gone to friction maybe ??

But theres also friction that we didnt reduce from experimental value which I thing that means I found the result with %10-15 error

Is that ok ?
 

Attachments

  • Force-distance.png
    Force-distance.png
    61.9 KB · Views: 448
Last edited:

Related Threads on Matlab Spline Fit

  • Last Post
Replies
1
Views
9K
Replies
1
Views
12K
Replies
10
Views
15K
  • Last Post
Replies
5
Views
43K
Replies
1
Views
7K
Replies
4
Views
3K
Replies
1
Views
2K
Replies
4
Views
1K
Replies
5
Views
3K
Top