Effacer les filtres
Effacer les filtres

How to average a dense set of data using desired resolution

3 vues (au cours des 30 derniers jours)
Alfredo Scigliani
Alfredo Scigliani le 23 Mar 2023
Modifié(e) : Vilém Frynta le 23 Mar 2023
I have this big set of data that clearly follows a trend and I would like to average all the points every 1 second or whichever resolution. I think there should be a faster way than selecting them one by one to average it, I am trying to get some info.
clear; clc;
x = [
0.00469 0.0087 0.01 0.011225 0.012467 0.016228 0.017322 0.017945 0.020644 0.021309 0.022041 0.022509 0.034475 0.034943 0.037016 0.037295 0.041646 0.04452 0.044746 0.045893 0.050003 0.050831 0.052807 0.05684 0.062056 0.064304 0.06551 0.065621 0.072389 0.072631 0.072915 0.074093 0.074747 0.079348 0.081387 0.083463 0.087077 0.08749 0.088706 0.091313 0.091354 0.097794 0.104067 0.105914 0.108019 0.116753 0.118103 0.119401 0.121492 0.12249 0.124109 0.125496 0.128734 0.129008 0.137781 0.140841 0.143406 0.145827 0.149928 0.150054 0.150055 0.15117 0.151272 0.152399 0.152978 0.155543 0.155605 0.157627 0.162498 0.163231 0.16426 0.166012 0.167404 0.167895 0.168325 0.169927 0.17021 0.17072 0.171476 0.172374 0.172385 0.174317 0.175911 0.176255 0.177138 0.180468 0.18445 0.186827 0.188077 0.190074 0.19052 0.193335 0.195153 0.19681 0.200621 0.201303 0.202696 0.203191 0.206947 0.207224 0.212933 0.213877 0.215318 0.215895 0.218079 0.218653 0.222995 0.223679 0.224646 0.226926 0.227495 0.228072 0.230485 0.230836 0.230934 0.232077 0.236197 0.236271 0.237802 0.240445 0.240545 0.240771 0.243432 0.245898 0.245936 0.246707 0.247277 0.248455 0.249176 0.252292 0.254137 0.25564 0.26191 0.262848 0.264155 0.264374 0.265596 0.266928 0.268874 0.269895 0.271001 0.271477 0.272346 0.272498 0.272675 0.273783 0.274057 0.274732 0.276176 0.27695 0.276981 0.277782 0.278918 0.280487 0.28096 0.283195 0.290217 0.292752 0.293241 0.293512 0.294967 0.295209 0.296445 0.29841 0.30115 0.301406 0.301433 0.301987 0.302507 0.303998 0.305792 0.307823 0.308956 0.309897 0.310395 0.311371 0.312571 0.312581 0.313017 0.314869 0.323422 0.3257 0.326314 0.326447 0.326823 0.327552 0.328176 0.330197 0.330345 0.331374 0.334027 0.33448 0.334783 0.335008 0.336672 0.347097 0.3473 0.350075 0.35098 0.352541 0.354958 0.356059 0.357325 0.357805 0.359327 0.359882 0.361282 0.361654 0.361739 0.362249 0.365798 0.365919 0.369304 0.370111 0.372884 0.373315 0.374559 0.376204 0.378897 0.382103 0.388499 0.389041 0.391741 0.392955 0.393078 0.396401 0.396811 0.397709 0.399032 0.401515 0.40249 0.403438 0.403554 0.403809 0.404691 0.407685 0.410673 0.414054 0.415084 0.41748 0.417687 0.418908 0.419548 0.423043 0.424294 0.425136 0.434095 0.435643 0.436709 0.436819 0.439525 0.441809 0.444022 0.450333 0.452903 0.454711 0.455348 0.455923 0.456029 0.456422 0.459604 0.461679 0.462877 0.465959 0.46708 0.471292 0.47498 0.475172 0.475389 0.476659 0.476758 0.476765 0.477031 0.477034 0.477447 0.478575 0.479295 0.480371 0.481492 0.482311 0.482917 0.483132 0.4836 0.484134 0.486336 0.487046 0.487299 0.490746 0.494387 0.495256 0.497342 0.500271 0.500317 0.501695 0.502911 0.50451 0.504943 0.505055 0.508514 0.508973 0.509516 0.509849 0.510524 0.513764 0.514342 0.514723 0.514872 0.515409 0.515937 0.518875 0.520119 0.521912 0.522053 0.525219 0.527065 0.527217 0.53127 0.531997 0.532328 0.534683 0.538023 0.538163 0.538769 0.539404 0.541226 0.541465 0.541967 0.543132 0.543483 0.543512 0.544096 0.544357 0.544932 0.545626 0.546518 0.547217 0.549758 0.550612 0.550631 0.551151 0.552452 0.552865 0.553143 0.553771 0.555098 0.555723 0.556046 0.556692 0.557898 0.559617 0.559632 0.56653 0.567009 0.568145 0.573398 0.574594 0.575274 0.577585 0.578313 0.578885 0.579987 0.580432 0.581109 0.58285 0.583498 0.583886 0.584921 0.587065 0.587519 0.587579 0.58771 0.589172 0.589602 0.589997 0.594309 0.595283 0.595905 0.5987 0.601807 0.602987 0.603453 0.607003 0.607106 0.608573 0.608845 0.609965 0.610698 0.611156 0.615384 0.615906 0.618809 0.621403 0.62278 0.623397 0.627736 0.628118 0.630982 0.63133 0.631341 0.632167 0.632516 0.632786 0.632893 0.634447 0.636308 0.636647 0.637394 0.637613 0.638679 0.63942 0.639475 0.639945 0.640261 0.64105 0.644439 0.644543 0.646717 0.64716 0.647211 0.647263 0.647424 0.64771 0.649749 0.650591 0.651154 0.654115 0.654478 0.655164 0.660403 0.661052 0.661303 0.661616 0.662467 0.662622 0.664465 0.667322 0.671025 0.67111 0.671989 0.675536 0.679479 0.680493 0.681191 0.683479 0.685082 0.685352 0.686146 0.686196 0.686225 0.690492 0.690868 0.695468 0.700636 0.701101 0.701509 0.701792 0.702247 0.702317 0.703878 0.703941 0.704887 0.709365 0.709537 0.715553 0.7181 0.720229 0.720494 0.720893 0.72099 0.723134 0.723846 0.724539 0.724879 0.725154 0.726006 0.726598 0.727488 0.728552 0.729348 0.732906 0.733101 0.733333 0.733667 0.734194 0.738271 0.738456 0.739449 0.739952 0.739995 0.741187 0.741756 0.742481 0.742736 0.743023 0.743302 0.74369 0.744724 0.746245 0.746378 0.749414 0.749501 0.749611 0.750031 0.750415 0.751011 0.752337 0.752462 0.755283 0.755985 0.75971 0.760456 0.761379 0.761559 0.761829 0.761839 0.763408 0.763435 0.763856 0.764929 0.767146 0.76726 0.767295 0.768255 0.768529 0.76981 0.770041 0.770768 0.772317 0.77277 0.773795 0.774521 0.774941 0.774967 0.776377 0.777726 0.783486 0.784672 0.784745 0.785747 0.785972 0.790539 0.79066 0.792787 0.793801 0.794247 0.794359 0.794868 0.797406 0.799207 0.799266 0.800136 0.80046 0.801149 0.802112 0.802393 0.805799 0.807205 0.810318 0.812475 0.812526 0.822351 0.82536 0.8259 0.826454 0.82655 0.827163 0.82873 0.832197 0.833525 0.833627 0.833749 0.834248 0.834451 0.835017 0.835474 0.838612 0.838889 0.842141 0.842475 0.843564 0.845216 0.85065 0.852407 0.85619 0.856884 0.857085 0.861557 0.86232 0.863489 0.866427 0.867138 0.867824 0.867991 0.868751 0.869847 0.870389 0.871553 0.874963 0.877214 0.879876 0.880946 0.881041 0.881686 0.884276 0.886394 0.88654 0.889024 0.895075 0.895763 0.896709 0.89899 0.901667 0.92286 0.928428 0.931573 0.932508 0.958969 0.959285 0.966525 0.967296 0.968492 0.969734 0.972318 0.972324 0.974141 ];
y = [
0.80528 0.64562 0.7 0.793458 0.813043 0.766762 0.734048 0.733398 0.819582 0.756235 0.718495 0.667408 0.629234 0.767601 0.743824 0.590143 0.779554 0.761395 0.822688 0.606969 0.932394 0.662306 0.806961 0.689375 0.867427 0.777223 0.641577 0.608569 0.766644 0.842595 0.65134 0.689746 0.732769 0.777866 0.716936 0.618486 0.569079 0.744086 0.695222 0.614351 0.732562 0.642543 0.671435 0.509444 0.706395 0.453125 0.648561 0.553778 0.78545 0.505204 0.653294 0.660017 0.558387 0.625183 0.662981 0.523873 0.513965 0.618664 0.606449 0.548198 0.5176 0.482032 0.458478 0.531614 0.518083 0.511984 0.487671 0.632311 0.495095 0.563435 0.559764 0.567523 0.594687 0.579135 0.661833 0.623742 0.573631 0.593816 0.533158 0.624416 0.628195 0.612084 0.633708 0.46468 0.666943 0.415515 0.489189 0.408365 0.593812 0.496433 0.473808 0.516928 0.588119 0.493858 0.543793 0.576961 0.662306 0.577834 0.464187 0.648496 0.617673 0.556932 0.570741 0.59753 0.512099 0.482524 0.590297 0.522105 0.425006 0.607814 0.51804 0.46804 0.623267 0.456525 0.432922 0.459532 0.601528 0.578053 0.451693 0.40878 0.500278 0.514728 0.472733 0.47005 0.595265 0.553248 0.507601 0.545793 0.557765 0.578889 0.511815 0.583396 0.497402 0.472937 0.497564 0.511449 0.453331 0.523376 0.498627 0.523775 0.511857 0.447116 0.474522 0.56627 0.570633 0.576563 0.493617 0.426735 0.564 0.524418 0.497071 0.449833 0.537249 0.534227 0.45032 0.542313 0.514466 0.362698 0.486351 0.500021 0.460537 0.369117 0.490131 0.544988 0.500021 0.406145 0.414834 0.514665 0.486379 0.380315 0.47957 0.469739 0.518343 0.454518 0.493915 0.519066 0.429586 0.543491 0.462223 0.384842 0.538838 0.413811 0.473397 0.503234 0.439037 0.36836 0.407247 0.452856 0.499255 0.398915 0.464977 0.52162 0.515723 0.549254 0.437427 0.397578 0.475363 0.407611 0.386477 0.441829 0.427243 0.324321 0.451728 0.490215 0.413568 0.441685 0.448713 0.520786 0.423857 0.390612 0.364845 0.480033 0.389663 0.38327 0.431223 0.460976 0.443638 0.328576 0.437218 0.416967 0.366405 0.335965 0.335873 0.412749 0.351164 0.351016 0.296967 0.372882 0.512175 0.387724 0.422714 0.352144 0.426664 0.356864 0.322462 0.291183 0.342015 0.427482 0.330716 0.385752 0.329791 0.413751 0.291167 0.452068 0.309299 0.430213 0.405468 0.398113 0.327577 0.314028 0.315712 0.295502 0.32361 0.324911 0.310893 0.281979 0.34924 0.402864 0.283832 0.267568 0.25448 0.298571 0.37767 0.373868 0.278857 0.214147 0.420911 0.291114 0.335709 0.33995 0.312315 0.303846 0.256152 0.360429 0.360716 0.401722 0.32595 0.370817 0.311387 0.340964 0.285687 0.311058 0.455486 0.357921 0.290849 0.312112 0.33266 0.214926 0.285677 0.193088 0.255912 0.247581 0.332855 0.269401 0.251248 0.27398 0.283548 0.375222 0.303604 0.234625 0.197771 0.273931 0.279426 0.28364 0.20535 0.248702 0.237436 0.205881 0.275331 0.201725 0.316321 0.226597 0.306648 0.306979 0.328476 0.237104 0.239884 0.213015 0.209803 0.300632 0.282938 0.182864 0.18531 0.228802 0.26723 0.222337 0.265782 0.293654 0.197893 0.261277 0.276125 0.325253 0.251959 0.231881 0.250884 0.354749 0.252916 0.262588 0.261132 0.305295 0.242703 0.30563 0.214794 0.26266 0.304594 0.274017 0.252107 0.248801 0.258919 0.250944 0.227974 0.237676 0.214035 0.2405 0.255753 0.256582 0.208805 0.274378 0.307904 0.118621 0.196045 0.283171 0.159809 0.160839 0.255256 0.198779 0.232843 0.325619 0.257546 0.261782 0.249742 0.157724 0.112924 0.173462 0.248 0.220729 0.203253 0.245482 0.170845 0.17999 0.034075 0.196457 0.158329 0.218735 0.285625 0.162757 0.233924 0.288465 0.159826 0.152422 0.165816 0.154683 0.229171 0.219591 0.272257 0.122807 0.158686 0.23933 0.243433 0.202875 0.192389 0.171271 0.229539 0.141984 0.174124 0.194803 0.146364 0.20925 0.170598 0.146018 0.263825 0.195842 0.210249 0.086206 0.177546 0.187132 0.155542 0.168859 0.070714 0.19417 0.168472 0.168872 0.127005 0.168236 0.177539 0.154429 0.165554 0.217187 0.163961 0.13325 0.186773 0.220556 0.170665 0.169902 0.112926 0.12719 0.112295 0.099143 0.100306 0.071185 0.13027 0.109643 0.117658 0.081351 0.075564 0.172287 0.136254 0.201121 0.102328 0.08915 0.170521 0.068228 0.168656 0.134089 0.116606 0.206608 0.162707 0.182244 0.153269 0.141955 0.128071 0.038279 0.107102 0.143664 0.127989 0.182769 0.084405 0.133795 0.151992 0.114101 0.131188 0.121489 0.047829 0.110572 0.080972 0.156716 0.122272 0.12134 0.083891 0.128522 0.077419 0.081904 0.08787 0.059451 0.092805 0.046723 0.112831 0.131469 0.130663 0.139785 0.063652 0.127872 0.086438 0.144811 0.082339 0.120753 0.11531 0.138242 0.121368 0.128117 0.120017 0.122149 0.111215 0.092866 0.124989 0.107351 0.047923 0.063395 0.111479 0.067648 0.096739 0.043001 0.073596 0.021702 0.130857 0.108312 0.092628 0.033314 0.056733 0.079198 0.068921 0.068764 0.109586 0.106157 0.129783 0.104211 0.113155 0.03192 0.092337 0.051723 0.072301 0.040144 0.131064 0.066336 0.095863 0.120184 0.093323 0.102077 0.093394 0.051252 0.052294 0.037677 0.086021 0.034701 0.083175 0.087888 0.054015 0.021229 0.091835 0.075401 0.029097 0.075937 0.084842 0.035379 0.031658 0.054243 0.085288 0.101882 0.030662 0.040419 0.071324 0.038831 -0.00071 0.055344 0.02901 0.073855 0.033783 0.090942 0.063111 0.063775 0.031704 0.041681 0.082311 0.075116 0.047857 0.08169 0.000464 0.031116 0.069075 0.032482 0.024482 0.031929 0.019796 0.051616 0.049967 0.058261 0.039221 0.056633 0.021771 0.02173 0.044482 0.006824 0.01219 0.008423 0.014469 0.03076 0.008262 0.038364 0.011016 0.025781 0.013119 0.013553 0.018508 0.033083 0.017039 0.025885 0.023107 0.066768 0.02533 0.038817 0.004143 0.044104 0.048077 0.042264 0.002508 0.01967 0.028636 -0.00033 0.004452 0.017808 0.015836 0.039663 0.022492 0.043269 0.064936 ];
I can graphically show what I am looking for:
It might be more simple that what I am trying but I am just not sure how to...

Réponse acceptée

Vilém Frynta
Vilém Frynta le 23 Mar 2023
Modifié(e) : Vilém Frynta le 23 Mar 2023
hey,
what you could do is as follows. to simplify this, let's assume that the length of the data is 1000.
  • divide your data, on your example you are representing the data with 8 averages and their standard deviations.
L = 1000; % assume length = 1000
seq = L/8; % seq = 125
  • now, we know that each sequence has 125 values. we can calculate average and standard deviation from every 125 values.
%avgs = mean(data(1:seq)) % calculate average from data on position 1:125
%stds = std(data(1:seq)) % calculate std from data ...
  • you can edit this and put in a for loop and save into structure or cell, up to your prefferences.
  • now you will have 8 averages and 8 stds, which you can plot.
  • this was just a guidance to give you some ideas, hope it helped.
edit: trying to do this with your numbers. code below.
% your variables
x = [0.00469 0.0087 0.01 0.011225 0.012467 0.016228 0.017322 0.017945 0.020644 0.021309 0.022041 0.022509 0.034475 0.034943 0.037016 0.037295 0.041646 0.04452 0.044746 0.045893 0.050003 0.050831 0.052807 0.05684 0.062056 0.064304 0.06551 0.065621 0.072389 0.072631 0.072915 0.074093 0.074747 0.079348 0.081387 0.083463 0.087077 0.08749 0.088706 0.091313 0.091354 0.097794 0.104067 0.105914 0.108019 0.116753 0.118103 0.119401 0.121492 0.12249 0.124109 0.125496 0.128734 0.129008 0.137781 0.140841 0.143406 0.145827 0.149928 0.150054 0.150055 0.15117 0.151272 0.152399 0.152978 0.155543 0.155605 0.157627 0.162498 0.163231 0.16426 0.166012 0.167404 0.167895 0.168325 0.169927 0.17021 0.17072 0.171476 0.172374 0.172385 0.174317 0.175911 0.176255 0.177138 0.180468 0.18445 0.186827 0.188077 0.190074 0.19052 0.193335 0.195153 0.19681 0.200621 0.201303 0.202696 0.203191 0.206947 0.207224 0.212933 0.213877 0.215318 0.215895 0.218079 0.218653 0.222995 0.223679 0.224646 0.226926 0.227495 0.228072 0.230485 0.230836 0.230934 0.232077 0.236197 0.236271 0.237802 0.240445 0.240545 0.240771 0.243432 0.245898 0.245936 0.246707 0.247277 0.248455 0.249176 0.252292 0.254137 0.25564 0.26191 0.262848 0.264155 0.264374 0.265596 0.266928 0.268874 0.269895 0.271001 0.271477 0.272346 0.272498 0.272675 0.273783 0.274057 0.274732 0.276176 0.27695 0.276981 0.277782 0.278918 0.280487 0.28096 0.283195 0.290217 0.292752 0.293241 0.293512 0.294967 0.295209 0.296445 0.29841 0.30115 0.301406 0.301433 0.301987 0.302507 0.303998 0.305792 0.307823 0.308956 0.309897 0.310395 0.311371 0.312571 0.312581 0.313017 0.314869 0.323422 0.3257 0.326314 0.326447 0.326823 0.327552 0.328176 0.330197 0.330345 0.331374 0.334027 0.33448 0.334783 0.335008 0.336672 0.347097 0.3473 0.350075 0.35098 0.352541 0.354958 0.356059 0.357325 0.357805 0.359327 0.359882 0.361282 0.361654 0.361739 0.362249 0.365798 0.365919 0.369304 0.370111 0.372884 0.373315 0.374559 0.376204 0.378897 0.382103 0.388499 0.389041 0.391741 0.392955 0.393078 0.396401 0.396811 0.397709 0.399032 0.401515 0.40249 0.403438 0.403554 0.403809 0.404691 0.407685 0.410673 0.414054 0.415084 0.41748 0.417687 0.418908 0.419548 0.423043 0.424294 0.425136 0.434095 0.435643 0.436709 0.436819 0.439525 0.441809 0.444022 0.450333 0.452903 0.454711 0.455348 0.455923 0.456029 0.456422 0.459604 0.461679 0.462877 0.465959 0.46708 0.471292 0.47498 0.475172 0.475389 0.476659 0.476758 0.476765 0.477031 0.477034 0.477447 0.478575 0.479295 0.480371 0.481492 0.482311 0.482917 0.483132 0.4836 0.484134 0.486336 0.487046 0.487299 0.490746 0.494387 0.495256 0.497342 0.500271 0.500317 0.501695 0.502911 0.50451 0.504943 0.505055 0.508514 0.508973 0.509516 0.509849 0.510524 0.513764 0.514342 0.514723 0.514872 0.515409 0.515937 0.518875 0.520119 0.521912 0.522053 0.525219 0.527065 0.527217 0.53127 0.531997 0.532328 0.534683 0.538023 0.538163 0.538769 0.539404 0.541226 0.541465 0.541967 0.543132 0.543483 0.543512 0.544096 0.544357 0.544932 0.545626 0.546518 0.547217 0.549758 0.550612 0.550631 0.551151 0.552452 0.552865 0.553143 0.553771 0.555098 0.555723 0.556046 0.556692 0.557898 0.559617 0.559632 0.56653 0.567009 0.568145 0.573398 0.574594 0.575274 0.577585 0.578313 0.578885 0.579987 0.580432 0.581109 0.58285 0.583498 0.583886 0.584921 0.587065 0.587519 0.587579 0.58771 0.589172 0.589602 0.589997 0.594309 0.595283 0.595905 0.5987 0.601807 0.602987 0.603453 0.607003 0.607106 0.608573 0.608845 0.609965 0.610698 0.611156 0.615384 0.615906 0.618809 0.621403 0.62278 0.623397 0.627736 0.628118 0.630982 0.63133 0.631341 0.632167 0.632516 0.632786 0.632893 0.634447 0.636308 0.636647 0.637394 0.637613 0.638679 0.63942 0.639475 0.639945 0.640261 0.64105 0.644439 0.644543 0.646717 0.64716 0.647211 0.647263 0.647424 0.64771 0.649749 0.650591 0.651154 0.654115 0.654478 0.655164 0.660403 0.661052 0.661303 0.661616 0.662467 0.662622 0.664465 0.667322 0.671025 0.67111 0.671989 0.675536 0.679479 0.680493 0.681191 0.683479 0.685082 0.685352 0.686146 0.686196 0.686225 0.690492 0.690868 0.695468 0.700636 0.701101 0.701509 0.701792 0.702247 0.702317 0.703878 0.703941 0.704887 0.709365 0.709537 0.715553 0.7181 0.720229 0.720494 0.720893 0.72099 0.723134 0.723846 0.724539 0.724879 0.725154 0.726006 0.726598 0.727488 0.728552 0.729348 0.732906 0.733101 0.733333 0.733667 0.734194 0.738271 0.738456 0.739449 0.739952 0.739995 0.741187 0.741756 0.742481 0.742736 0.743023 0.743302 0.74369 0.744724 0.746245 0.746378 0.749414 0.749501 0.749611 0.750031 0.750415 0.751011 0.752337 0.752462 0.755283 0.755985 0.75971 0.760456 0.761379 0.761559 0.761829 0.761839 0.763408 0.763435 0.763856 0.764929 0.767146 0.76726 0.767295 0.768255 0.768529 0.76981 0.770041 0.770768 0.772317 0.77277 0.773795 0.774521 0.774941 0.774967 0.776377 0.777726 0.783486 0.784672 0.784745 0.785747 0.785972 0.790539 0.79066 0.792787 0.793801 0.794247 0.794359 0.794868 0.797406 0.799207 0.799266 0.800136 0.80046 0.801149 0.802112 0.802393 0.805799 0.807205 0.810318 0.812475 0.812526 0.822351 0.82536 0.8259 0.826454 0.82655 0.827163 0.82873 0.832197 0.833525 0.833627 0.833749 0.834248 0.834451 0.835017 0.835474 0.838612 0.838889 0.842141 0.842475 0.843564 0.845216 0.85065 0.852407 0.85619 0.856884 0.857085 0.861557 0.86232 0.863489 0.866427 0.867138 0.867824 0.867991 0.868751 0.869847 0.870389 0.871553 0.874963 0.877214 0.879876 0.880946 0.881041 0.881686 0.884276 0.886394 0.88654 0.889024 0.895075 0.895763 0.896709 0.89899 0.901667 0.92286 0.928428 0.931573 0.932508 0.958969 0.959285 0.966525 0.967296 0.968492 0.969734 0.972318 0.972324 0.974141 ];
y = [0.80528 0.64562 0.7 0.793458 0.813043 0.766762 0.734048 0.733398 0.819582 0.756235 0.718495 0.667408 0.629234 0.767601 0.743824 0.590143 0.779554 0.761395 0.822688 0.606969 0.932394 0.662306 0.806961 0.689375 0.867427 0.777223 0.641577 0.608569 0.766644 0.842595 0.65134 0.689746 0.732769 0.777866 0.716936 0.618486 0.569079 0.744086 0.695222 0.614351 0.732562 0.642543 0.671435 0.509444 0.706395 0.453125 0.648561 0.553778 0.78545 0.505204 0.653294 0.660017 0.558387 0.625183 0.662981 0.523873 0.513965 0.618664 0.606449 0.548198 0.5176 0.482032 0.458478 0.531614 0.518083 0.511984 0.487671 0.632311 0.495095 0.563435 0.559764 0.567523 0.594687 0.579135 0.661833 0.623742 0.573631 0.593816 0.533158 0.624416 0.628195 0.612084 0.633708 0.46468 0.666943 0.415515 0.489189 0.408365 0.593812 0.496433 0.473808 0.516928 0.588119 0.493858 0.543793 0.576961 0.662306 0.577834 0.464187 0.648496 0.617673 0.556932 0.570741 0.59753 0.512099 0.482524 0.590297 0.522105 0.425006 0.607814 0.51804 0.46804 0.623267 0.456525 0.432922 0.459532 0.601528 0.578053 0.451693 0.40878 0.500278 0.514728 0.472733 0.47005 0.595265 0.553248 0.507601 0.545793 0.557765 0.578889 0.511815 0.583396 0.497402 0.472937 0.497564 0.511449 0.453331 0.523376 0.498627 0.523775 0.511857 0.447116 0.474522 0.56627 0.570633 0.576563 0.493617 0.426735 0.564 0.524418 0.497071 0.449833 0.537249 0.534227 0.45032 0.542313 0.514466 0.362698 0.486351 0.500021 0.460537 0.369117 0.490131 0.544988 0.500021 0.406145 0.414834 0.514665 0.486379 0.380315 0.47957 0.469739 0.518343 0.454518 0.493915 0.519066 0.429586 0.543491 0.462223 0.384842 0.538838 0.413811 0.473397 0.503234 0.439037 0.36836 0.407247 0.452856 0.499255 0.398915 0.464977 0.52162 0.515723 0.549254 0.437427 0.397578 0.475363 0.407611 0.386477 0.441829 0.427243 0.324321 0.451728 0.490215 0.413568 0.441685 0.448713 0.520786 0.423857 0.390612 0.364845 0.480033 0.389663 0.38327 0.431223 0.460976 0.443638 0.328576 0.437218 0.416967 0.366405 0.335965 0.335873 0.412749 0.351164 0.351016 0.296967 0.372882 0.512175 0.387724 0.422714 0.352144 0.426664 0.356864 0.322462 0.291183 0.342015 0.427482 0.330716 0.385752 0.329791 0.413751 0.291167 0.452068 0.309299 0.430213 0.405468 0.398113 0.327577 0.314028 0.315712 0.295502 0.32361 0.324911 0.310893 0.281979 0.34924 0.402864 0.283832 0.267568 0.25448 0.298571 0.37767 0.373868 0.278857 0.214147 0.420911 0.291114 0.335709 0.33995 0.312315 0.303846 0.256152 0.360429 0.360716 0.401722 0.32595 0.370817 0.311387 0.340964 0.285687 0.311058 0.455486 0.357921 0.290849 0.312112 0.33266 0.214926 0.285677 0.193088 0.255912 0.247581 0.332855 0.269401 0.251248 0.27398 0.283548 0.375222 0.303604 0.234625 0.197771 0.273931 0.279426 0.28364 0.20535 0.248702 0.237436 0.205881 0.275331 0.201725 0.316321 0.226597 0.306648 0.306979 0.328476 0.237104 0.239884 0.213015 0.209803 0.300632 0.282938 0.182864 0.18531 0.228802 0.26723 0.222337 0.265782 0.293654 0.197893 0.261277 0.276125 0.325253 0.251959 0.231881 0.250884 0.354749 0.252916 0.262588 0.261132 0.305295 0.242703 0.30563 0.214794 0.26266 0.304594 0.274017 0.252107 0.248801 0.258919 0.250944 0.227974 0.237676 0.214035 0.2405 0.255753 0.256582 0.208805 0.274378 0.307904 0.118621 0.196045 0.283171 0.159809 0.160839 0.255256 0.198779 0.232843 0.325619 0.257546 0.261782 0.249742 0.157724 0.112924 0.173462 0.248 0.220729 0.203253 0.245482 0.170845 0.17999 0.034075 0.196457 0.158329 0.218735 0.285625 0.162757 0.233924 0.288465 0.159826 0.152422 0.165816 0.154683 0.229171 0.219591 0.272257 0.122807 0.158686 0.23933 0.243433 0.202875 0.192389 0.171271 0.229539 0.141984 0.174124 0.194803 0.146364 0.20925 0.170598 0.146018 0.263825 0.195842 0.210249 0.086206 0.177546 0.187132 0.155542 0.168859 0.070714 0.19417 0.168472 0.168872 0.127005 0.168236 0.177539 0.154429 0.165554 0.217187 0.163961 0.13325 0.186773 0.220556 0.170665 0.169902 0.112926 0.12719 0.112295 0.099143 0.100306 0.071185 0.13027 0.109643 0.117658 0.081351 0.075564 0.172287 0.136254 0.201121 0.102328 0.08915 0.170521 0.068228 0.168656 0.134089 0.116606 0.206608 0.162707 0.182244 0.153269 0.141955 0.128071 0.038279 0.107102 0.143664 0.127989 0.182769 0.084405 0.133795 0.151992 0.114101 0.131188 0.121489 0.047829 0.110572 0.080972 0.156716 0.122272 0.12134 0.083891 0.128522 0.077419 0.081904 0.08787 0.059451 0.092805 0.046723 0.112831 0.131469 0.130663 0.139785 0.063652 0.127872 0.086438 0.144811 0.082339 0.120753 0.11531 0.138242 0.121368 0.128117 0.120017 0.122149 0.111215 0.092866 0.124989 0.107351 0.047923 0.063395 0.111479 0.067648 0.096739 0.043001 0.073596 0.021702 0.130857 0.108312 0.092628 0.033314 0.056733 0.079198 0.068921 0.068764 0.109586 0.106157 0.129783 0.104211 0.113155 0.03192 0.092337 0.051723 0.072301 0.040144 0.131064 0.066336 0.095863 0.120184 0.093323 0.102077 0.093394 0.051252 0.052294 0.037677 0.086021 0.034701 0.083175 0.087888 0.054015 0.021229 0.091835 0.075401 0.029097 0.075937 0.084842 0.035379 0.031658 0.054243 0.085288 0.101882 0.030662 0.040419 0.071324 0.038831 -0.00071 0.055344 0.02901 0.073855 0.033783 0.090942 0.063111 0.063775 0.031704 0.041681 0.082311 0.075116 0.047857 0.08169 0.000464 0.031116 0.069075 0.032482 0.024482 0.031929 0.019796 0.051616 0.049967 0.058261 0.039221 0.056633 0.021771 0.02173 0.044482 0.006824 0.01219 0.008423 0.014469 0.03076 0.008262 0.038364 0.011016 0.025781 0.013119 0.013553 0.018508 0.033083 0.017039 0.025885 0.023107 0.066768 0.02533 0.038817 0.004143 0.044104 0.048077 0.042264 0.002508 0.01967 0.028636 -0.00033 0.004452 0.017808 0.015836 0.039663 0.022492 0.043269 0.064936 ];
L = length(x);
seq = floor(L/8); % need to round down
% preallocate vectors
avgs = 1:L/seq;
stds = 1:L/seq;
% scan through the sequences with for loop and save avgs/stds into a vector
for q = 1:L/seq
avgs(q) = mean(y(1+1*(q-1):seq*q));
stds(q) = std(y(1+1*(q-1):seq*q));
end
% display averages and stds for control
disp(avgs)
0.6563 0.5904 0.5384 0.4805 0.4304 0.3834 0.3408 0.3019
disp(stds)
0.1081 0.1087 0.1200 0.1462 0.1644 0.1818 0.1964 0.2089
% plot the errorbar
errorbar(avgs,stds)
While this looks pretty good, there is one small error and that is: I have rounded down the number of sequences, because it was a decimal, which doesn't work for indexing. This means that not all numbers are scanned, probably some are left out.
missed = L/seq
missed = 8.0128
as you can see, the vector is not split into 8 parts, but into 8.0128 parts, meanwhile the for loop is going only over 8 parts. hope you understand.
you can either use what i did or you can try to polish and correct it.
hope my answers was helpful. if you think so, i would be glad if you could accept it.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by