gradient of discrete values

10 次查看(过去 30 天)
KHAN
KHAN 2019-11-13
评论: KHAN 2019-11-13
Hi All,
I need help in understanding the meaning of the gradient of the discrete values. Also, could any one help getting the value of the Gradient,dVph/dλ. I have attached my values for the Vph and the λ respectively.
The first column is Vph and the second column is λ. Thanks in advance.
With my best regards,
Yours,
Mohammed
VphL = [
1812.234616 1979.443463
1763.809653 963.2752452
1718.518132 625.6933573
1689.774915 461.4212035
1671.472611 365.1387634
1656.271536 301.5150316
1640.657059 256.0050024
1620.993485 221.3196438
1594.69773 193.5372415
1561.481568 170.5554267
1520.436705 150.9747575
1472.884234 134.065196
1420.109628 119.3183392
1365.093613 106.5033036
1310.040293 95.39422294
1257.10516 85.81837893
1207.87969 77.60745427
1163.539261 70.60528614
1124.397588 64.63905293
1090.438109 59.55245992
1061.22606 55.19723102
1036.062965 51.43895643
1014.364893 48.17204174
995.5081051 45.30667999
979.0419797 42.77499679
964.5883813 40.52260523
951.7297428 38.50158051
940.2370703 36.67820038
929.815684 35.02091992
920.4268855 33.5117202
911.8996075 32.13024338
904.1649683 30.86216425
897.2074067 29.69665889
890.9330138 28.6216598
885.1589823 27.62370432
879.8342136 26.69482177
874.8862036 25.82727128
870.3842188 25.01820183
866.100658 24.25674048
861.9991783 23.53832423
857.7839027 22.85192108
853.8706677 22.20605876
850.5313168 21.6048141
848.2875514 21.05809582
847.4362697 20.56947532
847.7751362 20.13035918
849.5859733 19.744137
852.6876696 19.40338164
856.4470579 19.09119537
860.3330799 18.79426291
863.3353019 18.49004652
865.6430603 18.18294346
866.9635213 17.86708218
867.3019069 17.54305487
866.8169084 17.21445846
863.4320659 16.84103687
859.5106462 16.47043559
855.0913346 16.10323727
852.3700277 15.77992151
849.5540436 15.46565939
846.6478221 15.16008516
843.6519119 14.86278809
840.5700517 14.57343886
837.4020204 14.29166115
834.1522689 14.01718028
830.8257734 13.74974694
827.4279908 13.48913453
823.9648423 13.23513723
820.4433753 12.987579
816.8717261 12.74631082
813.2563334 12.51116598
809.6064641 12.28202991
805.9306473 12.05878331
802.2387012 11.84133232
798.5420531 11.62961155
794.846841 11.42348302
791.1652355 11.22290149
787.5073357 11.02779503
783.8844331 10.83811186
780.310645 10.65384134
776.790879 10.47484919
773.3399844 10.30114009
769.9737856 10.13273133
766.6968558 9.969493083
763.5253051 9.811449882
760.4773047 9.658651287
757.5558869 9.510954522
754.778545 9.368402789
752.1641141 9.231053817
749.7134873 9.09874502
747.4509365 8.971601571
745.3746312 8.849433302
743.5007557 8.732269808
741.8451757 8.620135715
740.4014344 8.512797966
739.1887591 8.410325437
738.1969394 8.312452684
144.3579017 1.608952286
243.0446733 2.681511062
736.608884 8.045733303
736.5303649 7.965223431
736.6601133 7.888522416
737.0042927 7.815584681
737.5371952 7.74603167
738.2595376 7.679774136
739.1438241 7.61643548
740.1872909 7.555905653
741.3618163 7.497822221
742.6601643 7.442045341
744.0532845 7.388223644
745.5314206 7.336208286
747.0661402 7.285673596
748.6445432 7.236455573
750.2398943 7.188263408
751.83838 7.140939141
753.4160037 7.094234371
754.9575446 7.047991117
756.4428049 7.002010687
757.8549285 6.956131736
759.1776553 6.910203725
760.3971527 6.864103003
761.5039281 6.81774883
762.4784506 6.770973948
763.3128819 6.723719493
763.9903773 6.675849782
764.5133851 6.627400689
764.8635373 6.578227924
765.0384412 6.528328031
765.0309446 6.477657363
764.84106 6.426233808
764.4597277 6.373999073
763.8826267 6.320935837
763.0992887 6.266976815
762.1108508 6.212151333
760.913475 6.156447593
759.5116482 6.099921002
757.8952778 6.042509115
756.0528409 5.984139973
753.9863784 5.924850276
751.6916512 5.864626673
749.1742128 5.803532058
746.4136864 5.741428093
743.4123636 5.678353457
740.1755316 5.614368477
308.5664935 2.324392381
309.1347904 2.312723473
309.636397 2.300717791
310.0695586 2.288369211
310.4332584 2.275677184
310.7264074 2.262640648
310.9488769 2.249265519
311.1032919 2.23557734
311.1882243 2.221572055
311.2083911 2.207289299
311.1685949 2.192768283
311.0745677 2.178053725
310.932043 2.163189211
310.753061 2.148260824
310.5454737 2.133323707
310.3198144 2.118449933
310.0855206 2.103702348
309.8543618 2.089157969
309.6367034 2.074882515
309.4398785 2.060919906
309.2687375 2.047296564
309.1400317 2.034116578
309.054363 2.021375921
309.0184965 2.009110733
309.0262108 1.997272362
309.0854578 1.985904369
309.196771 1.975001909
309.3608898 1.964561557
309.5772306 1.954571617
309.845575 1.945022951
310.1622601 1.935885131
310.5262336 1.927144625
310.9270063 1.91872997
596.1025509 3.65788172
594.825564 3.629654391
593.7427489 3.602918962
592.8197226 3.577443217
592.0451887 3.553138598
591.4107619 3.529935855
590.8994878 3.50771638
590.5038757 3.48642
590.202971 3.465908773
589.9986952 3.446181327
589.8815938 3.427170225
589.8512118 3.408861466
589.8895814 3.391140667
589.9880965 3.37394938
590.1385119 3.357232423
590.3328967 3.34093754
590.5637648 3.325016056
590.8230085 3.309416811
591.1020318 3.294086969
591.4018492 3.279028053
591.7085992 3.264159491
592.0247921 3.249492192
592.3352217 3.234940091
592.6452263 3.220530477
592.9468438 3.206218181
593.2367842 3.191984063
593.5122385 3.177811933
593.7712641 3.163690534
594.0065675 3.149580454
594.2204627 3.135493739
594.4113637 3.121421725
594.5959735 3.107451493
594.757341 3.09349342
594.8953066 3.07954651
594.9968281 3.065543406
595.0724647 3.051539049
595.1191185 3.037517644
595.1371387 3.023481203
595.1258109 3.009426323
595.0843661 2.995349387
2336.375411 11.70616964
2303.939844 11.4909438
2272.176111 11.28101012
2241.119596 11.07647163
2210.668358 10.87675387
2180.78907 10.68162874
593.8637542 2.895792782
593.5483393 2.881391405
593.1943859 2.866931215
592.7973715 2.852391229
592.359675 2.837783893
591.8805793 2.82310667
591.3635841 2.80837709
590.8046412 2.793576693
590.2036279 2.778705816
589.5608345 2.763766727
588.8768703 2.748763146
588.1501073 2.733688329
587.3845098 2.718561528
586.5834616 2.703398997
350.3127257 1.60770972
350.592508 1.602261548
350.8569674 1.596789043
351.1074864 1.591298771
351.3380866 1.58576397
351.559653 1.580234116
351.7739288 1.574716953
351.9907855 1.569256335
352.2023474 1.563816602
352.4106441 1.558406476
352.6177424 1.553034702
352.8248865 1.547706276
353.0349193 1.542433098
353.2497906 1.537222993
353.4721331 1.532086621
353.7028211 1.527026883
571.3476862 2.456945011
570.6270953 2.444223354
569.9498818 2.431786162
569.317772 2.419637452
568.7295837 2.407768863
568.1883151 2.396189795
567.6940544 2.384897279
567.2486395 2.373895711
566.8489443 2.363168729
566.4937655 2.352708201
566.1815734 2.342504772
565.9105641 2.332548096
565.6787088 2.322827059
565.4814618 2.313320417
565.3182794 2.304023554
565.1880532 2.294929632
565.0898203 2.286032498
565.018708 2.277310335
564.9721797 2.268751027
564.9477167 2.260342708
564.9428368 2.252073829
564.95511 2.243933218
564.9800781 2.235901836
565.0176719 2.227978228
565.0656684 2.220152497
565.1239769 2.212423235
565.1883938 2.20477301
565.2569841 2.197193458
565.3277549 2.189676108
565.3993128 2.182214921
565.4698119 2.174802206
565.5360154 2.167425047
565.5982794 2.160084431
565.6552149 2.15277469
565.7072095 2.145496972
565.7512458 2.138239541
565.7862226 2.13099804
565.8111231 2.123768486
565.8250118 2.116547259
565.827034 2.109331087
565.8152682 2.102112779
565.7902949 2.094894507
565.7518903 2.087675444
565.6997901 2.080454626
565.6326179 2.073227027
565.5499887 2.065991307
565.4515885 2.058746406
565.3371739 2.05149153
565.206572 2.044226153
565.0596797 2.036950009
564.8959308 2.029661169
564.7158941 2.022361794
564.5196744 2.015052363
564.3080018 2.00773557
564.0798427 2.000407823
563.8332099 1.993062203
563.568208 1.985699251
563.2857225 1.978322246
562.9882809 1.97094017
562.6764681 1.963555112
562.3509333 1.956169361
562.0123859 1.948785382
378.1320896 1.307028725
378.3577531 1.30368316
378.4860813 1.300024309
378.6044501 1.296354297
378.7135153 1.292675466
559.1988212 1.902785771
558.8560555 1.895713792
558.826592 1.889745074
558.7364168 1.88360853
380.192725 1.277759509
380.381409 1.274472189
380.5597895 1.271170559
380.7350408 1.26787864
380.9075706 1.264597697
381.0849422 1.261352665
381.129129 1.257687744
381.1708167 1.254036679
381.210682 1.250401564
381.3807018 1.247213856
381.5508356 1.24404555
381.7271651 1.240916244
381.9041625 1.237807675
382.0820393 1.234720341
552.679069 1.78074609
552.6746661 1.775494457
383.116147 1.227170079
383.2868806 1.224127145
383.4586183 1.221105151
383.6315399 1.218104487
383.8058163 1.215125506
383.9748112 1.212147072
384.0201474 1.20879656
384.0693598 1.20547747
384.1295831 1.20221186
548.9041265 1.712999087
548.626403 1.707254508
548.3573797 1.701569566
548.0972267 1.69594428
547.8461281 1.690378712
547.9071755 1.685804913
547.9674348 1.681254392
548.0273939 1.676728445
547.789417 1.671318773
547.5614928 1.665969823
547.3443285 1.660683237
547.1382546 1.655459495
546.9436032 1.650299078
387.3216411 1.165450463
387.450145 1.162634281
545.8654982 1.633508735
545.7310457 1.628644345
545.6156499 1.62386318
545.5133044 1.619146735
545.4242285 1.614495133
545.3486033 1.609908381
545.2865677 1.605386366
545.4473801 1.601542988
908.5194223 2.660443649
545.788455 1.593974697
545.7639427 1.5896527
545.7533056 1.585394
545.753121 1.581188176
545.7666728 1.577044297
545.7937087 1.572961147
545.8339302 1.568937388
545.7646891 1.564620939
545.7139335 1.560379945
545.6742756 1.556192747
545.7731035 1.552421272
545.8825137 1.548699412
546.0038189 1.545030495
546.1346867 1.541407529
546.2741758 1.537827508
546.4219278 1.534289094
546.5773823 1.530790398
546.7399799 1.527329553
396.1077428 1.103712459
396.5595815 1.102159828
547.7307824 1.518446893
547.912524 1.515105282
548.0982762 1.511791609
548.2891312 1.508508669
548.4846033 1.505254898
548.6842182 1.502028777
548.8875133 1.498828836
549.0940379 1.495653652
549.3006966 1.492494629
74.96857238 0.203190255
549.478977 1.485588046
549.5684727 1.482161293
549.7792185 1.479077622
549.9899805 1.476009147
550.2004109 1.472954826
550.4101735 1.469913657
550.6189432 1.466884677
550.8264062 1.463866965
551.0347433 1.460866219
-208.3864056 -0.551122336
-288.5905343 -0.761395703
552.4283161 1.453973579
552.6421067 1.451039788
552.8536817 1.448114264
553.0627517 1.445196192
553.2690374 1.442284791
553.4722703 1.439379314
553.661159 1.436450424
553.8458743 1.433524614
554.0261581 1.430601194
554.2129603 1.427708356
554.1558134 1.424202172
554.0903718 1.420691182
554.0162724 1.41717449
554.1708752 1.414257885
554.3205106 1.411342229
554.4650775 1.40842726
554.6153214 1.405540205
554.7608763 1.40265466
554.9016988 1.399770505
555.0267979 1.39686007
1837.62932 4.614209773
1834.862033 4.596694119
556.9369741 1.392045062
557.0607832 1.389175627
557.1786482 1.386304476
557.1731051 1.383140023
557.1619342 1.379975983
557.1451386 1.376812361
557.240642 1.373939906
557.3303517 1.371066138
557.414362 1.368191297
557.4927893 1.365315674
557.5657721 1.362439614
557.6334713 1.359563511
557.6960706 1.356687813
416.5033812 1.010961689
416.5549692 1.008845028
556.7203547 1.345325412
556.763606 1.342459885
556.804045 1.339600216
556.8420052 1.336747167
556.8778359 1.33390153
556.9119022 1.331064129
556.9445824 1.328235814
118224.5318 281.3348918
99363.68133 235.9383413
559.0694557 1.324626748
559.0796736 1.321783748
559.0884885 1.318949719
559.0963371 1.31612563
559.1036598 1.313312453
559.1110891 1.3105116
559.1186595 1.307723072
559.1270231 1.304948311
421.6355475 0.981958324
421.6870637 0.979988773
558.2389112 1.294576974
558.2820053 1.291933951
558.3287473 1.289310528
558.3794464 1.286707293
558.4343899 1.284124778
558.493841 1.281563458
558.5580383 1.279023746
1547.028026 3.535077709
1544.492035 3.521914753
559.8004549 1.273857035
559.8210162 1.271255375
559.8470345 1.268676876
559.8787107 1.266121849
559.9162169 1.263590537
559.9596965 1.261083116
560.0092642 1.258599696
560.0650059 1.256140323
560.1121431 1.253671769
560.1746809 1.251247713
560.2527502 1.248868171
560.3606574 1.246564699
560.4739758 1.244282604
560.5925902 1.242021501
812.5685845 1.796642873
812.1019168 1.791983543
811.6487344 1.787372697
560.916951 1.232738206
560.850694 1.230117506
560.7803285 1.227498317
560.9047333 1.225315087
561.035067 1.223153498
807.7359834 1.757496195
807.3235613 1.753106591
806.9247312 1.748763862
806.5387694 1.744466165
806.1649219 1.740211605
431.4326994 0.929466581
431.7893509 0.92840377
805.7622256 1.729090806
805.4179082 1.724963008
805.080215 1.720865524
804.7482977 1.716796368
804.4212939 1.712753539
804.0983287 1.708735022
803.7785168 1.704738799
803.4609647 1.700762848
563.8937983 1.191339264
802.7165062 1.692626414
802.3752249 1.688646844
802.1169655 1.68485697
801.8562378 1.681076468
801.5918753 1.677302846
801.3227124 1.673533629
801.0475875 1.669766371
800.7653476 1.665998661
565.4080621 1.17409958
565.49862 1.172059379
565.5823503 1.170012781
565.7344618 1.168115113
565.879802 1.166210651
566.0178865 1.164298437
566.1482474 1.162377555
566.2704367 1.160447134
566.3840277 1.158506356
566.4678077 1.15651197
171.0738372 0.348616138
171.1623369 0.348146956
562.1298618 1.141255967
562.1492371 1.139177873
562.1646929 1.137099547
562.1762048 1.135020941
562.1837698 1.132942052
562.1874067 1.130862919
562.1871555 1.128783622
562.183077 1.126704286
562.1752523 1.124625071
562.1637818 1.122546179
562.1487847 1.120467845
562.130398 1.118390339
562.1087748 1.11631396
562.0840837 1.114239035
562.0565069 1.112165919
562.0262392 1.110094985
561.9934862 1.108026628
561.9584628 1.105961256
561.9213913 1.10389929
561.8825003 1.101841159
561.8420226 1.0997873
561.8001934 1.097738148
561.7572491 1.095694139
561.7134254 1.093655705
561.6689558 1.091623271
561.6240701 1.089597249
561.5789932 1.087578041
561.5339434 1.085566033
561.4891317 1.083561594
561.4447603 1.081565074
561.4010219 1.079576801
561.3580987 1.077597081
561.3161615 1.075626198
561.2753696 1.073664408
561.2358696 1.071711945
561.1977957 1.069769015
561.161269 1.067835799
561.1263975 1.065912452
561.0932759 1.063999101
561.0619859 1.06209585
561.0325963 1.060202775
561.0051627 1.058319929
560.9797283 1.056447341
560.9563241 1.054585016
560.9349692 1.052732936
560.9156713 1.050891064
560.8984271 1.049059341
560.8832229 1.047237689
560.8700353 1.045426013
560.8588313 1.043624201
560.8495692 1.041832125
560.8421993 1.040049643
560.8366642 1.0382766
560.8328995 1.036512829
560.8308346 1.034758152
560.8303929 1.033012384
560.831493 1.031275329
560.8340486 1.029546785
560.8379697 1.027826543
560.8431628 1.026114392
560.8495317 1.024410115];

回答(1 个)

Walter Roberson
Walter Roberson 2019-11-13
Your data needs to be sorted before you can compute numeric gradients.
Note that your second column (lambda) is the independent variable, not your first column.
SVL = sortrows(VphL, [2 1]);
dVphdL = gradient(SVL(:,1), SVL(:,2));
plot(SVL(:,2), dVphdL)
xlabel('lamda')
ylabel('dVph/dlambda')
  3 个评论
Walter Roberson
Walter Roberson 2019-11-13
Numeric gradients are estimated through central and forward differences. Those require that the data be sorted for the estimates to be meaningful. Only data at most two points away is used in the calculation for a point.
Numeric gradients do not involve fitting an equation to the data and then taking the derivative of the equation and evaluating it at the points, so order matters.
Also, Vph and lambda values are not equally spaced. Does this affect the results?
It affects the error estimation but not the calculations. As long as the data is sorted by the independent variable, then the calculations that are done take into account that the data might not be equally spaced.
KHAN
KHAN 2019-11-13
Hi Walter Roberson,
Thanks again for your fast reply and answering my questions! Please, if you do not mind, what do you recommend, i.e., what is the best way to solve my problem regarding not sorting the data? I have atached my plot showing the Velocity versus wavelength.The velocity= frequency times wavelength. So, I have calculated the wavelength from the equation: wavelength= velocity/frequency. Also, I have attached the equation which requires the dVph/dλ. I am waiting for your reply. I appreciate your time and effort for answering my questions. Thanks.
With my best regards,
Mohammed

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by