Help Numerical integration in matlab

Click For Summary
SUMMARY

The discussion focuses on performing numerical integration in MATLAB to calculate the period of a damped harmonic oscillator using the trapezoidal rule with the 'trapz' function. The user is tasked with finding T = 2 * (integral from x1 to x2 of (1/v_num) dx), where x1 and x2 represent consecutive extrema. Despite previous experience with MATLAB, the user encounters discrepancies in the calculated period, which ranges from 20-60 seconds instead of the expected 2-5 seconds.

PREREQUISITES
  • Understanding of numerical integration techniques, specifically the trapezoidal rule.
  • Familiarity with MATLAB programming and its syntax.
  • Knowledge of damped harmonic oscillators and their mathematical modeling.
  • Ability to interpret lab data for integration purposes.
NEXT STEPS
  • Review MATLAB's 'trapz' function documentation for advanced usage and examples.
  • Learn about MATLAB's 'integral' function for more accurate numerical integration.
  • Study the mathematical principles behind damped harmonic oscillators to clarify the integration limits.
  • Explore data visualization techniques in MATLAB to better analyze the relationship between x_num and t_num.
USEFUL FOR

Students and researchers in physics or engineering, MATLAB users performing numerical analysis, and anyone studying damped harmonic oscillators and their integration methods.

Pereza0
Messages
3
Reaction score
0
Help! Numerical integration in matlab

So (assuming the period in a damped harmonic oscillator is constant, because it is right?)

I have been asked to find T= 2* (integral from x1 to x2 of(1/v_num)dx) where x1 and x2 are two consecutive extrema (?? not sure what he means with this, i supossed he mean a max and a min, I am spanish and my teacher is german, he doesn't speak spanish and all, and his accent makes me hard to understand what he says in english too. He never told us anything about numerical integration)

where x_num is
Spoiler:
76X1
x_num =

2.5031
3.2700
3.9152
4.3457
4.7871
5.0556
5.1416
5.1963
5.2314
5.0160
4.8071
4.4870
4.0921
3.6850
3.2715
2.7567
2.3136
1.8144
1.3074
0.8447
0.3929
-0.0224
-0.4132
-0.7527
-1.0654
-1.3259
-1.5381
-1.6895
-1.8126
-1.9019
-1.9227
-1.9228
-1.9328
-1.8343
-1.7121
-1.6082
-1.4477
-1.2862
-1.1291
-0.9619
-0.7710
-0.5915
-0.4040
-0.2357
-0.0740
0.0758
0.2112
0.3394
0.4424
0.5282
0.6087
0.6603
0.6900
0.7287
0.7280
0.7292
0.7063
0.6620
0.6168
0.5745
0.5165
0.4525
0.3928
0.3282
0.2538
0.1862
0.1219
0.0601
0.0010
-0.0522
-0.1013
-0.1441
-0.1818
-0.2099
-0.2347
-0.2515


or the mid point version 75X1
x_num_mid =

2.5031
3.2700
3.9152
4.3457
4.7871
5.0556
5.1416
5.1963
5.2314
5.0160
4.8071
4.4870
4.0921
3.6850
3.2715
2.7567
2.3136
1.8144
1.3074
0.8447
0.3929
-0.0224
-0.4132
-0.7527
-1.0654
-1.3259
-1.5381
-1.6895
-1.8126
-1.9019
-1.9227
-1.9228
-1.9328
-1.8343
-1.7121
-1.6082
-1.4477
-1.2862
-1.1291
-0.9619
-0.7710
-0.5915
-0.4040
-0.2357
-0.0740
0.0758
0.2112
0.3394
0.4424
0.5282
0.6087
0.6603
0.6900
0.7287
0.7280
0.7292
0.7063
0.6620
0.6168
0.5745
0.5165
0.4525
0.3928
0.3282
0.2538
0.1862
0.1219
0.0601
0.0010
-0.0522
-0.1013
-0.1441
-0.1818
-0.2099
-0.2347

and v_num is
Spoiler:
75X1
v_num =

9.5859
8.0662
5.3803
5.5174
3.3571
1.0750
0.6840
0.4380
-2.6924
-2.6117
-4.0005
-4.9371
-5.0884
-5.1679
-6.4351
-5.5394
-6.2402
-6.3369
-5.7840
-5.6470
-5.1912
-4.8853
-4.2436
-3.9096
-3.2555
-2.6531
-1.8917
-1.5386
-1.1163
-0.2611
-0.0004
-0.1254
1.2314
1.5276
1.2986
2.0062
2.0181
1.9649
2.0898
2.3855
2.2444
2.3429
2.1041
2.0214
1.8723
1.6927
1.6030
1.2876
1.0721
1.0056
0.6454
0.3718
0.4835
-0.0095
0.0153
-0.2865
-0.5532
-0.5645
-0.5288
-0.7256
-0.8005
-0.7455
-0.8080
-0.9298
-0.8455
-0.8029
-0.7731
-0.7379
-0.6660
-0.6139
-0.5351
-0.4701
-0.3518
-0.3100
-0.2101

Ive done integration in MATLAB before, but never derived from lab data.

The trouble I am having here is that whatever I do, the period I get is about 20-60 secs while looking at x_num and t_num side by side the logical thing would be for it to be 2-5 secs. Been using trapz.
 
Physics news on Phys.org


ok i figured it own alone

Thanks anyway!
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
10K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
23K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
12K
  • · Replies 5 ·
Replies
5
Views
5K
Replies
3
Views
4K