Clear Filters
Clear Filters

what am i doing wrong?

8 views (last 30 days)
Arpita
Arpita on 27 Apr 2024
Answered: Walter Roberson on 27 Apr 2024
a = [6.935619321 6.044821712 3.134221992 4.03723168 44.35409695 24.3929123 27.83599663 2.360239752 31.63092825 7.189890853 0.639270435 1.404702752 87.21610528 7.956564044 4.976439534 14.98701648 20.04658871 3.245097342 60.65204845 8.473849158 12.88126928 152.5899599 162.5176806 165.3003645 172.9442562 36.1144365 17.27680243 13.61212521 35.61080325 12.91920333 4.060340798 5.183427853 16.82114757 21.53888165 30.87388237 0.500171677 13.90364604 18.71917525 12.20078559 35.42235807 2.360556574 5.146571947 0.688984049 0.571231374 10.98994753 0.610325415 16.73235181 28.38199434 49.11590007 37.24850295 4.96158691 30.82454871 8.600581955 18.60764689 44.97155227 6.267863223 1.29369648 80.35825674 50.37336917 120.402486
704.7425374 497.8575062 231.0523862 303.9155734 2398.86889 2363.393303 2052.214632 1401.527665 1195.385704 1141.068931 530.1204071 719.0627586 658.2118105 1670.911183 964.4133012 613.2864152 651.5200114 1032.004328 883.933512 926.9718212 669.3164675 855.1756096 877.7346682 873.1162954 852.6209747 870.9879069 2228.003245 835.1785985 495.4477079 2145.984107 980.4355009 1184.624074 354.6949055 444.278561 809.808274 1070.888888 1208.93713 130.9940865 532.878654 692.6306627 828.6450502 628.5106037 748.6055007 786.6259368 885.2770485 933.6825812 851.4713508 1035.56264 884.3207665 1159.39765 1312.298832 1862.273744 271.4662628 562.0994173 347.4607626 2316.859913 485.7127394 399.7244779 1237.155371 1478.748961
-841.7576842 -535.4401458 -492.1288074 -385.4577355 -2610.862233 -472.6483553 -423.2464952 -2812.842669 -2427.79961 -2235.386912 -1690.107759 -1626.896759 -257.4801241 -3329.131946 -2816.665045 -1218.245293 -728.4260221 -1227.67158 -1397.417942 -1363.334056 -1092.449912 -1208.551645 -1102.110806 -1160.550311 -1007.357699 -1157.746282 -1345.887656 -2679.35944 -1226.720221 -2617.088883 -2738.784324 -1261.888107 -490.367718 -716.0875752 -457.6734926 -538.4369091 -773.0059077 -1498.429036 -1446.717147 -1746.137904 -1961.961576 -134.6617489 -1178.250329 -1312.036393 -341.3551273 -686.7375961 -846.7331219 -954.3391692 -106.2146133 -1271.62049 -1178.210577 -2191.348181 -1944.777367 -641.3823654 -915.4784362 -678.3189285 -2481.942741 -2654.875547 -591.1355787 -437.3663647
4862.910289 1355.933205 1740.109509 697.266154 10957.77786 20938.3703 3942.430228 312.8555661 7835.792313 2051.919986 179.9962327 27454.99512 20558.87867 -20481.51341 -921.0031122 3468.856724 25559.93643 714.210672 12542.34206 4634.476687 50754.55309 23954.5459 30343.97296 36195.75984 49421.33637 -49706.22754 5029.02627 2461.715672 -74020.41277 -3078.082319 673.2815554 1659.872489 4132.459252 6291.012785 7587.811162 104.6994939 1976.167568 5056.462596 3920.106703 9410.246322 591.1871644 -2207.887378 107.0944364 86.73960378 1894.612108 161.7588786 3030.729399 10092.23733 17197.12127 72133.96032 1163.169661 4682.375674 17574.82174 3891.35099 24981.90974 -2283.196074 261.7046238 11028.39779 17849.93272 21717.11903
-677.7197919 -319.6740693 -71.42845025 -207.168951 -752.3694602 -877.2136527 -386.8745055 -45.27745973 -526.6557927 -125.4235623 -18.68792141 1975.357795 -490.7437904 -1383.403587 -129.5860491 -163.1735662 -302.2616691 -90.66935992 -602.3054636 -138.6030629 -221.7409722 -1286.176506 -1304.778913 -1301.634913 -1339.894613 -593.4283686 -243.6596197 -216.8395299 -577.2791256 -397.6489027 -67.06907873 -83.43416971 -289.3598963 -266.6904773 -319.4891615 -27.11016096 -2570.197199 -270.8016951 -199.2744951 -580.5057735 -77.01200107 -471.0391248 -36.41676677 -31.92916616 -183.4049563 -82.08328851 -262.4306585 -265.7770551 -351.7104009 -579.6475265 -92.16428519 -332.8595157 -173.2395123 -267.0596267 -493.5616198 -1712.910856 75.48626306 -401.6144294 -415.2271257 -4048.657506];
f1 = (.01 + .1)/2;
f2 = (2 + 4)/2;
f3 = (1 + 5)/2; % centre frequency in Hz
f4 = (5 + 10)/2;
f5 = (.1+1)/2;
Q = []
Q = []
for i = 1:size(a(:,i))
q(:,i) = a(:,i);
b1 = log(q(:,i));
b2 = log([f1 f2 f3 f4 f5]');
p = abs(polyfit(b2, b1, 2));
n = abs(p(1));
q0 = abs(exp(p(2)));
Q(:,i) = q0 * [f1 f2 f3 f4 f5]'.^n;
i = i + 1;
end
Warning: Colon operands must be real scalars. This warning will become an error in a future release.

Answers (1)

Walter Roberson
Walter Roberson on 27 Apr 2024
size(a(:,i)) is a vector of length 2.
You should use size(a,1)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!