Hello everyone. I have the following problem: my code cannot calculate the Type A uncertainty, which means the standard deviation.

2 ビュー (過去 30 日間)
There are individual frequencies, and for each one, there is a single permittivity (ε') value on each sheet. I need to take each frequency, gather all the permittivity data from the sheets for that particular frequency, and calculate their mean and standard deviation.
For example, for a frequency of 100 MHz, there is one permittivity value on each sheet. I need to collect all the permittivity values from each sheet for 100 MHz and calculate the mean and standard deviation. This process needs to be repeated for each frequency.
The calculation of the mean value is working well, but I'm having trouble with the calculation of the standard deviation. In AVR_water.xlsx, you will find the data for the calculations, and AVR_water_2.xlsx contains the results calculated in Excel.
And yes, ChatGPT helps me with writing the code because I'm not proficient in Matlab.
Thank you all

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 10 月 24 日
編集済み: Dyuman Joshi 2023 年 10 月 24 日
Use sheetnames and readmatrix, as the xls functions are deprecated.
Here, we take the advantage of matrix operations and the fact that the data you have is stored uniformly and frequency values are unique -
excel_file = 'AVR_water.xlsx';
names = sheetnames(excel_file);
n = numel(names);
%Preallocation
C = cell(1,n);
for k=1:n
C{k} = readmatrix(excel_file,'Sheet', names(k));
end
%Concatenate the data into a 3D array
%Each page corresponds to the data of each sheet
C = cat(3,C{:});
%As epsilon values are stored in the 2nd column for each sheet
%use indexing to data the corresponding mean and standard deviation
m = reshape(mean(C(:,2,:), 3),[],1);
s = reshape(std(C(:,2,:), [], 3),[],1);
T_result = table(C(:,1,1), m, s, 'VariableNames', {'Frequency (MHz)', 'Average Permittivity ε1', 'Type A Uncertainty'});
disp(T_result)
Frequency (MHz) Average Permittivity ε1 Type A Uncertainty _______________ _______________________ __________________ 100 79.61 0.024389 129.5 79.63 0.022826 159 79.648 0.021834 188.5 79.663 0.021184 218 79.676 0.021042 247.5 79.685 0.02118 277 79.691 0.021505 306.5 79.694 0.021734 336 79.692 0.021998 365.5 79.688 0.022332 395 79.682 0.022483 424.5 79.673 0.022603 454 79.663 0.022812 483.5 79.654 0.022614 513 79.644 0.022374 542.5 79.638 0.022081 572 79.632 0.021906 601.5 79.624 0.021851 631 79.617 0.021843 660.5 79.609 0.021835 690 79.601 0.022066 719.5 79.593 0.022461 749 79.584 0.022837 778.5 79.573 0.022477 808 79.561 0.022099 837.5 79.548 0.021903 867 79.535 0.021507 896.5 79.522 0.021069 926 79.507 0.020423 955.5 79.492 0.019999 985 79.478 0.019766 1014.5 79.464 0.019733 1044 79.451 0.020235 1073.5 79.437 0.021258 1103 79.425 0.022691 1132.5 79.412 0.024157 1162 79.398 0.025596 1191.5 79.383 0.026408 1221 79.365 0.026496 1250.5 79.347 0.026514 1280 79.329 0.027142 1309.5 79.312 0.028405 1339 79.296 0.030218 1368.5 79.28 0.032336 1398 79.264 0.034877 1427.5 79.249 0.037448 1457 79.234 0.039882 1486.5 79.216 0.041679 1516 79.197 0.042638 1545.5 79.176 0.043047 1575 79.154 0.042762 1604.5 79.131 0.041965 1634 79.106 0.040603 1663.5 79.081 0.03894 1693 79.055 0.037541 1722.5 79.029 0.036048 1752 79.002 0.034131 1781.5 78.974 0.0317 1811 78.944 0.0286 1840.5 78.913 0.025323 1870 78.88 0.02192 1899.5 78.847 0.018856 1929 78.815 0.016974 1958.5 78.784 0.016429 1988 78.755 0.01672 2017.5 78.726 0.01748 2047 78.698 0.01821 2076.5 78.668 0.018779 2106 78.637 0.019163 2135.5 78.605 0.01965 2165 78.573 0.020164 2194.5 78.541 0.02063 2224 78.509 0.021072 2253.5 78.477 0.021257 2283 78.446 0.021274 2312.5 78.415 0.020951 2342 78.384 0.020398 2371.5 78.354 0.020023 2401 78.323 0.020013 2430.5 78.291 0.020278 2460 78.259 0.020768 2489.5 78.225 0.021134 2519 78.192 0.021124 2548.5 78.159 0.020905 2578 78.127 0.020436 2607.5 78.094 0.019995 2637 78.063 0.020053 2666.5 78.032 0.021042 2696 78.001 0.022976 2725.5 77.97 0.025631 2755 77.938 0.028584 2784.5 77.906 0.031737 2814 77.872 0.034742 2843.5 77.838 0.037369 2873 77.802 0.039589 2902.5 77.766 0.041409 2932 77.728 0.04247 2961.5 77.689 0.04319 2991 77.649 0.043624 3020.5 77.607 0.043673 3050 77.566 0.043523 3079.5 77.524 0.043036 3109 77.481 0.042229 3138.5 77.436 0.040784 3168 77.39 0.039079 3197.5 77.344 0.036695 3227 77.297 0.034054 3256.5 77.25 0.031236 3286 77.201 0.028322 3315.5 77.153 0.02535 3345 77.105 0.022383 3374.5 77.056 0.019509 3404 77.007 0.016883 3433.5 76.958 0.014527 3463 76.909 0.012639 3492.5 76.86 0.011192 3522 76.811 0.010686 3551.5 76.761 0.011072 3581 76.71 0.01203 3610.5 76.66 0.013586 3640 76.609 0.015378 3669.5 76.558 0.017338 3699 76.507 0.019276 3728.5 76.456 0.021098 3758 76.405 0.022533 3787.5 76.354 0.023732 3817 76.302 0.024702 3846.5 76.25 0.025133 3876 76.199 0.025098 3905.5 76.148 0.024495 3935 76.099 0.023394 3964.5 76.049 0.021948 3994 76 0.019913 4023.5 75.95 0.017884 4053 75.9 0.015803 4082.5 75.851 0.013919 4112 75.802 0.012238 4141.5 75.753 0.010965 4171 75.704 0.010089 4200.5 75.654 0.0097361 4230 75.603 0.0095495 4259.5 75.552 0.0099234 4289 75.5 0.010601 4318.5 75.448 0.01149 4348 75.396 0.012524 4377.5 75.342 0.013698 4407 75.287 0.015062 4436.5 75.233 0.016126 4466 75.177 0.016857 4495.5 75.121 0.017718 4525 75.064 0.017963 4554.5 75.007 0.018579 4584 74.95 0.018888 4613.5 74.892 0.018711 4643 74.832 0.01821 4672.5 74.773 0.017256 4702 74.712 0.016134 4731.5 74.651 0.014983 4761 74.591 0.013879 4790.5 74.53 0.012806 4820 74.47 0.012074 4849.5 74.409 0.011747 4879 74.347 0.011989 4908.5 74.286 0.012402 4938 74.224 0.012829 4967.5 74.163 0.013207 4997 74.101 0.013287 5026.5 74.039 0.013147 5056 73.976 0.01273 5085.5 73.913 0.012181 5115 73.849 0.01147 5144.5 73.785 0.010762 5174 73.72 0.010091 5203.5 73.656 0.00972 5233 73.591 0.0096712 5262.5 73.527 0.0099922 5292 73.461 0.010139 5321.5 73.396 0.010694 5351 73.33 0.011303 5380.5 73.265 0.011808 5410 73.201 0.01262 5439.5 73.138 0.011961 5469 73.074 0.011778 5498.5 73.01 0.011713 5528 72.945 0.011594 5557.5 72.88 0.011347 5587 72.815 0.010928 5616.5 72.75 0.010505 5646 72.684 0.010128 5675.5 72.619 0.0095782 5705 72.554 0.0090437 5734.5 72.488 0.0085925 5764 72.421 0.0081432 5793.5 72.353 0.0077805 5823 72.284 0.0075574 5852.5 72.214 0.006979 5882 72.146 0.0068274 5911.5 72.076 0.0067365 5941 72.006 0.0066613 5970.5 71.936 0.0067039 6000 71.865 0.0069214
However, in case the data you have is not uniformly stored or is not unique, we can utilize the functions - splitapply or accumarray

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by