How to code this summation equation?
I need to calculate a parameter called SigmaI and BER, where the equation is
Here I is a 512*512 matrix. But the value of SigmaI that I calculated is not same as reported values.I think there is some error in writing the code. Also I need to calculate SigmaI for each F points (F is 1*757 matrix), but what I get is the value of SigmaI at the last point of F only. i.e, I need to generated SigmaI as 1*757 matrix. I am confused how to include it in the for loop. Similary BER also needed as a 1*757 matrix. Can anyone help me to get the right answer. The code is as follows,
clc;close all;clear all;
lambda = 532;
k = 2*pi/lambda;
z=linspace(1,757,757);
z_diff = (diff(z)) ;
z_diff = [0 z_diff];
tilt_angle=10;
beta=(pi/180)*tilt_angle;
Lx = 0.1;
Ly = Lx;
Nx = 512;
Ny = Nx ;
dx = Lx/Nx;
dy = Ly/Ny;
x = (-Nx/2:Nx/2-1)*dx;
y = (-Ny/2:Ny/2-1)*dy;
[X,Y] = meshgrid(x,y);
r = sqrt(X.^2 + Y.^2);
kx = meshgrid(-Nx/2:Nx/2-1)/(Nx.*dx);
ky = meshgrid(-Ny/2:Ny/2-1)/(Ny.*dy);
kz = ones(Nx);
Kx=cos(beta).*kx + sin(beta).*kz;
Ky=ky;
Kz=-sin(beta).*kx + cos(beta).*kz;
K2 = Kx.^2 + Ky.^2 + Kz.^2;
delfx = 1/(Lx);
delfy = delfx;
R = randn(Nx,Ny) ;
R = R – mean(R(:,:));
R = R/std(R(:,:));
Phi = [2.50310494762771e-07 2.50946965543003e-07 4.74127533715154e-07 5.24210357233832e-06 2.42362427581638e-07 1.42653443399616e-07 5.16930235276850e-07 9.04590700562310e-07 2.29541191637123e-06 3.60105794008093e-07 9.17845719860523e-08 2.50390367004531e-07 1.09738615765455e-06 1.00311041468925e-06 6.50810613011221e-08 3.02640252523566e-07 5.31047019902531e-07 1.80313245178286e-06 3.04099822876624e-06 1.47008194185741e-07 4.08290582950848e-08 3.82118426499270e-06 5.29334397036188e-07 4.87810778598663e-06 1.18782521297988e-06 1.16666772914768e-06 1.69778706192608e-06 7.67426466736916e-06 5.27799451227444e-06 4.23216916272082e-07 2.66828750584071e-05 2.46205729358867e-06 2.80169965568206e-06 2.97378024567976e-07 2.21170607901861e-07 3.41285818450589e-07 3.85275104621375e-08 4.05141179263807e-07 1.17629321652161e-06 4.95233464403551e-06 1.80125151270180e-06 2.81483058944610e-07 1.24528365857859e-05 6.86781782456521e-06 2.95828059847895e-06 1.27035361174474e-06 6.34388599513081e-07 2.32012818083199e-06 2.81784487117724e-06 1.46096455213802e-06 1.60178082889894e-06 1.94791694377124e-07 6.35459501021705e-08 8.30940388112504e-08 2.53354933929590e-07 4.31247522543152e-06 9.63180625859285e-07 8.03726503455623e-07 2.98282116276067e-07 9.25402679823575e-08 1.61856374619784e-07 1.73242501417858e-07 2.31570160754109e-07 1.78600321810053e-07 1.25598618058698e-07 1.63418364388577e-06 1.02774042441542e-06 8.32018926678718e-08 2.53586554087675e-07 2.53508325030189e-07 4.07413642129177e-08 2.42096085408459e-07 5.91587468209778e-07 1.27761778023523e-07 1.65773731666773e-07 1.79565395840267e-07 3.78521468221561e-07 1.21471607158554e-07 3.25378687175317e-07 1.25569084575180e-07 5.49035746100893e-08 4.07733632799329e-08 4.79103771763424e-07 3.27135102365317e-07 2.10496092551324e-07 1.33641668807187e-06 1.68227872575447e-06 1.52265748820018e-06 2.53683706505161e-07 1.25630494723704e-07 1.12347756326375e-06 2.53692684133802e-07 2.10500428113819e-07 2.52934873659000e-07 6.77249701528946e-07 2.95386782896753e-07 3.16617852613830e-07 3.59879226900604e-07 2.81244834536819e-07 2.35438339516804e-07 3.40806542459708e-07 6.44683615098099e-08 5.05945401350734e-07 2.57387924440325e-07 7.82108421793457e-08 2.52513556939930e-07 7.41154472489689e-08 8.95664707278605e-08 3.44823854262242e-07 2.57498619329261e-07 2.07939465354519e-06 7.18570183290631e-07 3.25198024230522e-07 2.11933525065655e-07 8.30783371984955e-08 1.65710628194624e-07 5.48396993890243e-08 5.95342783012939e-08 2.28819020334242e-07 1.99067722101735e-07 2.40425372248607e-07 2.51916559208949e-07 2.98446361528618e-07 2.82958505602994e-07 2.10599141757522e-07 4.60997674322361e-08 2.59856693650578e-07 1.47642122461920e-07 3.93574284250877e-07 3.94729289526600e-08 6.37347851352551e-08 2.51536627057736e-07 2.28438571372065e-07 1.90144303446780e-07 4.73626330414131e-08 6.44142268235402e-08 1.72106272576708e-06 1.70721924857358e-06 2.94643811973548e-07 3.55943119776846e-08 9.36518317402136e-08 4.31201179335937e-08 1.56428758776995e-07 3.19975996745435e-07 3.34275554966361e-07 1.20064760586921e-06 4.30984033789707e-07 2.15616245567332e-07 3.03074660779611e-07 3.29934827134432e-07 -2.24864187842034e-08 2.33412514429474e-07 3.21092520408291e-07 3.38617740923693e-07 6.04579881670076e-07 1.91481555229955e-07 9.38472397526705e-08 6.13052684855612e-07 3.97260343618278e-06 2.45355935394897e-07 3.47585309986832e-07 3.38923893338132e-07 2.20926360286704e-07 5.25446559955282e-07 2.84158336921376e-07 4.04755442008443e-07 3.35541338245773e-07 3.76856346223440e-07 2.75568777774655e-07 2.09025928742013e-07 7.10170870233622e-08 2.95787195332815e-07 5.59078661720798e-07 2.51150081156080e-07 4.02707325242296e-08 8.24148001852386e-08 2.57363940284162e-07 3.55816103375846e-07 3.95777597622744e-07 3.27993323594138e-07 3.52690891300866e-07 3.52278318886910e-07 5.06712192595194e-08 1.23808524289852e-07 8.39347385990663e-07 2.02892942754780e-07 7.97641133582245e-08 3.64530615247902e-07 9.11185642215493e-07 2.44511041473120e-07 3.24963966176285e-07 1.11685979674259e-07 2.86261990645848e-07 3.75634147009314e-08 2.16925989302430e-07 3.84116828662608e-07 2.71791109589261e-07 1.06845659312697e-07 2.02225581949648e-07 3.02535099485185e-07 3.11957552477906e-08 9.15881915538412e-08 9.18891121954120e-07 3.70106500980225e-07 2.25779726927071e-07 2.86067288473873e-07 5.66382866246259e-07 4.26632108086086e-07 4.53045634671475e-07 1.17973378714372e-06 3.40969918417227e-07 2.48643473538260e-07 2.64505922988546e-07 2.38444406096982e-07 3.47101823144428e-07 3.37625374999722e-07 3.20790426924069e-07 5.02178252920690e-08 1.73576015527609e-07 8.57402376593969e-07 1.80131811857122e-07 2.76964595681315e-07 2.14838038341036e-07 2.21053263051776e-07 1.59406260405821e-07 4.59614264881235e-08 3.78789455759776e-07 2.58966590318316e-07 7.75696011578299e-08 3.39990416320565e-07 3.24572509489827e-07 3.52020828992088e-08 6.49912862168267e-08 2.22828739301052e-07 2.13473046057573e-07 1.70720547021041e-07 2.19582224668132e-07 2.05914598785446e-07 1.14899310738254e-06 1.03415047080757e-07 1.89177690522258e-06 2.24175047702725e-07 3.76150153666139e-07 9.18124634120261e-08 2.27678254839140e-07 8.61346207114181e-08 3.38947999645138e-06 1.71880093129416e-07 2.22461873169689e-07 3.72427593494344e-08 6.76102058093114e-08 1.13163515787091e-06 7.04052219453715e-07 3.28310827940334e-07 2.12060821359437e-07 2.68576701610855e-07 2.04744061114503e-07 1.14622616867334e-07 4.35675529886048e-08 5.29665131717990e-08 3.50574437154752e-08 5.32920831968263e-08 1.04801149974382e-07 2.08316009852988e-07 2.77349913208742e-07 1.48756450473382e-07 3.78517042358300e-07 1.19222278136494e-07 4.57902170141890e-08 2.03249187200450e-07 9.32437812713631e-08 6.61503340988668e-07 1.01572927594225e-06 3.26294032932256e-07 2.26313604682662e-07 7.01012285236915e-08 7.61666326540900e-08 4.16954886967803e-08 4.41719683698357e-08 4.02549730011751e-08 4.41603434482274e-08 3.50371730851861e-08 3.00718061774876e-07 3.50372423542925e-08 5.32741630316562e-08 2.09046711312522e-07 3.75611845531339e-06 2.26535469768828e-07 4.62710159517236e-07 5.55357457448765e-07 4.16702305525217e-07 2.05922476618442e-07 2.06490274401431e-07 2.33754328058605e-07 1.66615319203810e-07 2.13390792614979e-07 2.54792444311713e-07 4.20241426628409e-07 6.95047952441784e-07 6.02254152247896e-07 1.56218004764843e-07 1.99836446669293e-07 1.62974708502310e-07 2.93420921132526e-07 1.67909832369442e-07 1.53692619622575e-07 8.89709805825161e-08 1.64148574413349e-07 1.82871518257336e-07 1.99566615308843e-07 1.59784291140960e-07 1.87893662090374e-07 2.77364481028229e-07 1.10443572547260e-07 2.18556580353372e-07 1.83932131011210e-07 7.94652011731045e-08 2.43919458395486e-07 1.59781205439559e-07 1.94642054497664e-07 1.29989372686070e-07 1.90910393259075e-07 2.84452061601644e-07 3.30006526167654e-07 1.93485493531741e-07 2.40209860863182e-07 4.15333943239071e-07 2.91343651778087e-07 2.58377576473351e-07 1.81274762632482e-07 1.88893039486970e-07 2.19428417763272e-07 2.20994023873646e-07 2.27950728874121e-07 1.64400439994395e-07 1.00341668297253e-07 1.67577483763212e-07 5.61980802260245e-08 3.04539633123467e-08 3.19018898206730e-08 3.89504322796163e-08 3.19941498021468e-07 5.41874921040340e-06 1.01776790218898e-06 1.29079721421378e-06 5.77887058141474e-07 2.79939362285509e-07 5.55989804582382e-08 2.11144624551603e-07 5.73140726411827e-08 5.35992572193921e-08 2.80066251579433e-07 1.76964657359828e-07 3.25199602895421e-07 2.18271466195228e-07 1.80628024038326e-07 4.69550563668357e-08 1.48055689005769e-07 1.82317859358405e-07 1.33063533148151e-07 2.62672490298873e-08 2.52416541944235e-08 2.08244390466210e-07 3.06261128674104e-07 2.18183988930487e-07 1.32114003617060e-07 3.13731744862144e-07 2.78980205382911e-07 2.42110700965470e-08 1.28818767334643e-07 3.48416502648141e-07 1.43250842379859e-07 2.58790299254369e-08 2.36803673262810e-08 2.54679999490770e-08 1.53423624973069e-07 2.11044574009824e-07 2.45219073821534e-08 5.40329423903049e-08 4.07828910547019e-08 2.86866659397290e-08 5.74108869690081e-08 3.17780519921456e-08 2.89072270765441e-07 6.46668413187508e-08 3.89801393203052e-07 1.62322978572959e-07 2.69026419637955e-07 4.76120100475985e-07 5.32185045407108e-07 1.57575408820348e-07 2.08858600548085e-07 1.87565977660685e-07 2.01108310997773e-07 3.95620143987532e-08 5.24866345380986e-08 8.64930520826212e-08 9.74072997804584e-07 2.54439638933078e-08 1.00154777975012e-07 9.42429455464106e-07 2.23088555779751e-07 2.02097796370716e-07 1.99163165408265e-07 9.26536634692885e-08 1.31298738607173e-07 1.97726692783641e-07 2.28150683478771e-07 2.17170907865184e-07 2.69677497220439e-08 1.54765400027711e-07 6.26255760215395e-08 1.46771827369792e-07 1.81515822529873e-07 1.72918459779846e-07 8.15990146285526e-08 9.85514009220808e-08 7.03396855430348e-07 5.93657045438661e-07 1.51834395684521e-07 9.76927764035926e-08 1.18527867299870e-07 2.71435324116586e-08 5.68571003566081e-08 1.65983256102705e-07 2.29129793972797e-07 5.88646431511064e-08 3.08684402204026e-05 2.38265317337181e-06 4.30752744717656e-07 1.04689461805175e-07 2.32270648752108e-07 6.07211466407868e-07 1.95341105985221e-08 7.38231690963101e-08 1.95129857199575e-07 4.01671898332107e-08 4.75072551754564e-08 2.49046064060719e-06 1.78142428447807e-07 2.60935684174315e-07 4.29594269700864e-08 1.14070714922750e-07 5.26390027271695e-08 6.74132420131039e-08 2.11045265009953e-07 7.27021148761358e-07 2.83886081059763e-07 2.76343292567963e-08 1.61294742863238e-07 1.83304573271511e-07 2.45251911632262e-07 9.18095053702886e-07 9.40457085677553e-07 2.90451584499496e-07 1.04003175628026e-07 1.08284695915254e-07 5.44402482199441e-08 2.02578013696944e-08 5.88615942025308e-08 1.04406254724335e-07 1.20598226687063e-07 5.71264670628078e-07 3.15144191075623e-07 2.23052176438872e-08 2.98936409995515e-08 2.92428609360162e-07 2.47505388371339e-07 2.72866577624107e-07 2.69881858030521e-07 1.85519336468060e-07 2.56402576998181e-07 8.88653855726949e-08 1.23281438816645e-07 3.74059740200056e-08 3.63466577344003e-08 1.20887062612203e-06 5.31728280982040e-07 2.22245937870703e-08 1.24471844746278e-07 5.11735373064063e-07 3.13008213548308e-07 5.70247343660301e-08 7.23194564373494e-07 1.79616235944090e-07 6.78737172874271e-08 1.87999018332358e-07 1.56051038058590e-07 2.31029093824182e-08 3.65957708093627e-08 5.13581582166058e-07 2.55008648105981e-08 1.44166238137747e-07 3.81609462756446e-07 2.16242665285891e-07 2.34087134829968e-07 2.55408939395098e-07 5.31844204547311e-08 1.37230800917903e-07 2.24923680386313e-07 7.91242025449375e-08 1.56574476334133e-07 1.34926252415438e-07 1.70013819330808e-08 1.48130847036606e-07 1.10651211565701e-07 1.58123074045499e-07 1.47865663105776e-07 1.14316450201195e-07 2.02955526741989e-08 1.49518466142608e-07 2.99469635848321e-08 4.06175629714119e-07 2.32871553385763e-07 1.70948094081342e-07 1.86984334344187e-07 1.54774299548728e-07 1.27005955203776e-07 7.29605614875902e-08 4.26639317987837e-08 5.91930531596668e-08 1.50666658228087e-08 4.86748534643297e-08 1.64538615062307e-08 1.32252962938291e-07 1.06729078335828e-07 1.39785078669013e-07 1.39779800669610e-07 9.26422941859900e-08 1.13233915195479e-07 8.32946711657419e-08 1.67451405167575e-07 3.65621117891888e-08 2.21661117907828e-07 3.65652178907218e-08 1.41441861581090e-06 3.30075312403152e-07 2.05346680636497e-08 2.16432978289422e-07 1.92694668921994e-07 1.99379501668891e-07 2.60904461669433e-07 2.16709099204294e-07 1.33136064843243e-07 1.52413473502972e-07 7.53889226907776e-07 3.22036453180506e-07 1.68931528429636e-07 1.04094510285934e-07 1.60098934336117e-07 1.02657996503878e-07 6.83661821001145e-08 1.61931255758191e-07 2.01320024686194e-07 1.07534006069169e-07 1.07910634894973e-07 9.46522813533042e-08 1.66743437525985e-07 1.78365196465516e-07 1.90349497426267e-07 1.99051143944893e-07 1.10969246755729e-07 1.11264782143939e-07 1.02006294022338e-07 1.24767050443006e-07 1.04932154146443e-07 1.03659587531759e-07 4.90478970104965e-08 9.01107885624077e-08 9.30802687007756e-08 2.06842405795697e-07 1.53448550376276e-07 9.79061221486547e-08 8.26140384317179e-08 1.50146254483116e-07 1.40136146748372e-07 1.56837338087257e-07 1.76198808159403e-07 1.99122966368083e-07 1.23858764266714e-07 1.06727895602262e-07 8.15204687804434e-08 1.88227798887152e-08 2.31668781894091e-08 7.67325491571661e-07 1.97158231154847e-07 1.04232262587474e-07 8.81089549804027e-09 1.09695696650620e-08 3.67828021042941e-07 2.42873900856430e-07 9.30400519863338e-08 1.22815336391232e-08 1.04498084973760e-07 4.13726864269242e-07 1.28584375991528e-08 1.20376581165868e-07 1.07046398186240e-07 5.96207309583810e-08 3.66763563633301e-08 1.21422552113772e-07 1.39822102904246e-07 1.58475758239753e-07 8.54716186106630e-08 9.47107273229749e-08 1.57282457487923e-07 2.22341833330773e-07 1.47297286955243e-07 2.19435143761748e-07 1.39688617089499e-07 7.24259126481027e-08 7.09641458863346e-08 1.19226547380480e-07 7.87372467318109e-08 9.72314598010880e-08 7.74647075656411e-09 9.47412998435404e-08 1.16751285273194e-07 1.13487779361823e-07 1.13827758524977e-07 2.72522446715463e-07 8.16170870703966e-08 8.72321297381038e-08 9.95784392252335e-08 2.65989252708394e-09 1.06630932742284e-07 9.36921419305549e-08 8.41656329617571e-08 1.30269792124746e-08 4.86904164038956e-06 1.01469686899418e-07 1.47172552045969e-07 1.11949067863535e-07 9.34802107168088e-08 6.41098286680338e-08 6.68095594366830e-09 4.65659962399765e-08 1.74321722504626e-07 1.53177157686198e-07 1.72679939394816e-07 9.26791009109865e-08 7.38280843033631e-09 1.21431764801520e-08 1.83474589517062e-08 5.49758746890643e-08 5.49686356365556e-08 5.41396143667257e-07 1.02078716839878e-08 1.46280082306786e-07 9.20039209747377e-08 1.07464173701763e-08 4.37249887631680e-08 1.20696543908951e-07 7.37023067237918e-08 1.54370995646110e-07 8.75880053587604e-08 1.38972473988507e-07 1.50011697718075e-07 1.13900910702895e-07 7.30960487245964e-08 1.06352204500379e-07 7.15892552073097e-09 1.26382007766409e-08 2.34492999966371e-07 9.25652500580458e-08 8.91104525001921e-08 1.04346566674604e-08 7.96833204055166e-08 3.41626685510968e-07 1.46859973263572e-07 6.99097620123092e-08 5.60565018753087e-08 9.18716519344181e-08 5.82078430390537e-09 8.51757309259611e-08 1.41028716092150e-07 7.10210717526897e-09 3.02205722277794e-08 2.76205242367368e-07 9.08403872147274e-08 8.55641175181640e-08 8.07674139440669e-08 5.64950026938399e-09 1.47871928050032e-07 1.37623718221666e-07 9.60980796219824e-08 9.05395061229061e-09 3.58713661087815e-07 3.78246981154481e-07 1.97627162656081e-08 4.78463482905684e-08 5.47976120635378e-07 5.98012738422856e-07 1.38288635243591e-07 3.97209746106909e-08 1.04405402152745e-07 1.64230983323839e-08 2.14721179480984e-08 4.85083210883807e-08 1.22646011220379e-06 8.39456826640735e-09 8.27662116573820e-08 3.58891263221149e-07 9.16048888640066e-08 1.21278839928491e-07 2.31054125718236e-07 1.00889365297461e-07 1.19358834432565e-07 2.43427211256917e-07 9.11020950715102e-08 1.38162844699562e-07 8.00915682468241e-08 4.98258405386454e-09 7.30080219716715e-08 1.52701681888474e-07 2.93328698184570e-07 1.35353313498113e-07 4.59682925254202e-08 9.08782411223864e-08 2.20927979357592e-08 9.05503229704100e-08 6.68343694641667e-08 7.33025736057753e-08 7.49958147508063e-08 6.22824091009223e-09 8.02682015058001e-06 3.67877032868707e-07 7.19496678750717e-08 3.17758490462365e-09 5.75563157661276e-09 3.24272951280416e-09 1.00381201383279e-07 1.88260239049035e-07 7.07194739983604e-08 4.68947848174950e-09 4.16252458503278e-09 7.94576959843098e-08 2.74009776209153e-07 1.42430916804990e-07 1.26235913248699e-07 1.39626029880374e-07 1.16782761195100e-07 1.00256563902946e-07 -2.95101260456139e-09 6.83432403678117e-08 1.27348806727558e-07 5.96766339731236e-08 1.03604721020808e-07 1.21085249476580e-07 6.80561072346092e-08 2.39948064835149e-09 1.00688731186191e-08 2.43035685127838e-08 4.13254891501583e-08 9.63544005596039e-09 2.53883818143423e-07 7.44890597640385e-07];
w0=0.002;
F=2*(pi^2)*(k^2).*z_diff.*Phi;
x0 = linspace(-0.02,0.02,Nx);y0=x0;[X0,Y0] = meshgrid(x0,y0);
Uin=exp(-(X0.^2+Y0.^2)/w0^2);
x = x + z_diff(1)*tan(beta);
screen1 = exp(1i*((Kx.*x) + (Ky.*y))).*delfx.*delfy.*sqrt(F(1)).*R ;
Uout = Uin.*exp(1i.*screen1);
c=[0.740664357812470 0.715162315217582 0.689780546528124 0.664556687838984 0.639501229779350 0.614618312979130 0.589909677254809 0.565375929219662 0.541017064806704 0.516832720551119 0.492822307973243 0.468985091286926 0.445320235117717 0.421826835235231 0.398503939126698 0.375350560217132 0.352365687964806 0.329548295192595 0.306897343515746 0.284411787427262 0.262090577416753 0.239932662380474 0.217936991503006 0.196102515739251 0.174428188990141 0.152912969040777 0.131555818312352 0.110355704466664 0.0893116008928944 0.0684224870996102 0.0476873490298864 0.0271051793136574 0.00667497746850089 0.0136042499421828 0.0337334891863653 0.0537137192700918 0.0735459118688980 0.0932310312800026 0.112770034392025 0.132163870669524 0.151413482150099 0.170519803452171 0.189483761791847 0.208306277007520 0.226988261591059 0.245530620724636 0.263934252322323 0.282200047075789 0.300328888503445 0.318321653002534 0.336179209903699 0.353902421527639 0.371492143243500 0.388949223528713 0.406274504030009 0.423468819625392 0.440532998486862 0.457467862143721 0.474274225546305 0.490952897130006 0.507504678879476 0.523930366392895 0.540230748946220 0.556406609557339 0.572458725050048 0.588387866117797 0.604194797387153 0.619880277480917 0.635445059080876 0.650889888990134 0.666215508194993 0.681422651926368 0.696512049720699 0.711484425480339 0.726340497533411 0.741080978693105 0.755706576316408 0.770217992362264 0.784615923449129 0.798901060911951 0.813074090858528 0.827135694225279 0.841086546832386 0.854927319438336 0.868658677793846 0.882281282695167 0.895795790036781 0.909202850863477 0.922503111421817 0.935697213210995 0.948785793033077 0.961769483042646 0.974648910795838 0.987424699298783 1.00009746705545 1.01266782811491 1.02513639211797 1.03750376434332 1.04977054575300 1.06193733303735 1.07400471865938 1.08597329089862 1.09784363389434 1.10961632768826 1.12129194826677 1.13287106760249 1.14435425369543 1.15574207061353 1.16703507853271 1.17823383377643 1.18933888885472 1.20035079250267 1.21127008971854 1.22209732180122 1.23283302638735 1.24347773748787 1.25403198552414 1.26449629736359 1.27487119635488 1.28515720236266 1.29535483180181 1.30546459767133 1.31548700958769 1.32542257381781 1.33527179331163 1.34503516773420 1.35471319349739 1.36430636379121 1.37381516861470 1.38324009480640 1.39258162607448 1.40184024302645 1.41101642319850 1.42011064108442 1.42912336816425 1.43805507293243 1.44690622092571 1.45567727475060 1.46436869411057 1.47298093583279 1.48151445389465 1.48996969944983 1.49834712085410 1.50664716369079 1.51487027079592 1.52301688228302 1.53108743556759 1.53908236539135 1.54700210384610 1.55484708039729 1.56261772190731 1.57031445265850 1.57793769437581 1.58548786624928 1.59296538495611 1.60037066468257 1.60770411714556 1.61496615161393 1.62215717492952 1.62927759152798 1.63632780345927 1.64330821040796 1.65021920971321 1.65706119638862 1.66383456314170 1.67053970039319 1.67717699629614 1.68374683675467 1.69024960544263 1.69668568382193 1.70305545116068 1.70935928455115 1.71559755892740 1.72177064708287 1.72787891968756 1.73392274530517 1.73990249040993 1.74581851940328 1.75167119463032 1.75746087639608 1.76318792298160 1.76885269065981 1.77445553371120 1.77999680443936 1.78547685318630 1.79089602834756 1.79625467638721 1.80155314185264 1.80679176738913 1.81197089375438 1.81709085983270 1.82215200264920 1.82715465738367 1.83209915738443 1.83698583418192 1.84181501750219 1.84658703528021 1.85130221367304 1.85596087707287 1.86056334811985 1.86510994771484 1.86960099503199 1.87403680753115 1.87841770097023 1.88274398941727 1.88701598526258 1.89123399923051 1.89539834039132 1.89950931617273 1.90356723237146 1.90757239316461 1.91152510112087 1.91542565721170 1.91927436082231 1.92307150976254 1.92681740027765 1.93051232705897 1.93415658325440 1.93775046047891 1.94129424882478 1.94478823687186 1.94823271169764 1.95162795888723 1.95497426254328 1.95827190529575 1.96152116831153 1.96472233130413 1.96787567254306 1.97098146886325 1.97403999567435 1.97705152696986 1.98001633533631 1.98293469196218 1.98580686664685 1.98863312780943 1.99141374249746 1.99414897639556 1.99683909383401 1.99948435779718 2.00208502993198 2.00464137055607 2.00715363866619 2.00962209194621 2.01204698677524 2.01442857823560 2.01676712012071 2.01906286494297 2.02131606394144 2.02352696708957 2.02569582310279 2.02782287944605 2.02990838234126 2.03195257677470 2.03395570650435 2.03591801406711 2.03783974078601 2.03972112677735 2.04156241095768 2.04336383105087 2.04512562359498 2.04684802394913 2.04853126630031 2.05017558367013 2.05178120792145 2.05334836976503 2.05487729876606 2.05636822335072 2.05782137081251 2.05923696731876 2.06061523791685 2.06195640654055 2.06326069601621 2.06452832806891 2.06575952332861 2.06695450133616 2.06811348054936 2.06923667834885 2.07032431104407 2.07137659387907 2.07239374103836 2.07337596565262 2.07432347980443 2.07523649453394 2.07611521984447 2.07695986470806 2.07777063707106 2.07854774385950 2.07929139098462 2.08000178334822 2.08067912484798 2.08132361838281 2.08193546585808 2.08251486819086 2.08306202531507 2.08357713618662 2.08406039878854 2.08451201013601 2.08493216628138 2.08532106231914 2.08567889239087 2.08600584969017 2.08630212646748 2.08656791403493 2.08680340277114 2.08700878212594 2.08718424062516 2.08732996587524 2.08744614456794 2.08753296248490 2.08759060450230 2.08761925459532 2.08761909584274 2.08759031043135 2.08753307966046 2.08744758394630 2.08733400282638 2.08719251496389 2.08702329815202 2.08682652931821 2.08660238452849 2.08635103899165 2.08607266706347 2.08576744225093 2.08543553721630 2.08507712378131 2.08469237293121 2.08428145481885 2.08384453876873 2.08338179328099 2.08289338603538 2.08237948389527 2.08184025291152 2.08127585832643 2.08068646457760 2.08007223530177 2.07943333333869 2.07876992073487 2.07808215874743 2.07737020784777 2.07663422772538 2.07587437729149 2.07509081468279 2.07428369726507 2.07345318163688 2.07259942363312 2.07172257832864 2.07082280004183 2.06990024233815 2.06895505803365 2.06798739919850 2.06699741716044 2.06598526250827 2.06495108509530 2.06389503404273 2.06281725774310 2.06171790386362 2.06059711934957 2.05945505042762 2.05829184260918 2.05710764069365 2.05590258877174 2.05467683022873 2.05343050774771 2.05216376331278 2.05087673821232 2.04956957304210 2.04824240770851 2.04689538143169 2.04552863274867 2.04414229951646 2.04273651891521 2.04131142745123 2.03986716096009 2.03840385460964 2.03692164290309 2.03542065968197 2.03390103812916 2.03236291077188 2.03080640948460 2.02923166549207 2.02763880937220 2.02602797105897 2.02439927984538 2.02275286438630 2.02108885270135 2.01940737217775 2.01770854957318 2.01599251101859 2.01425938202100 2.01250928746633 2.01074235162217 2.00895869814052 2.00715845006058 2.00534172981146 2.00350865921493 2.00165935948813 1.99979395124624 1.99791255450517 1.99601528868428 1.99410227260896 1.99217362451332 1.99022946204283 1.98826990225688 1.98629506163147 1.98430505606170 1.98230000086442 1.98028001078079 1.97824519997880 1.97619568205582 1.97413157004115 1.97205297639850 1.96996001302854 1.96785279127132 1.96573142190885 1.96359601516744 1.96144668072028 1.95928352768979 1.95710666465011 1.95491619962948 1.95271224011267 1.95049489304337 1.94826426482658 1.94602046133099 1.94376358789132 1.94149374931069 1.93921104986296 1.93691559329504 1.93460748282926 1.93228682116561 1.92995371048410 1.92760825244698 1.92525054820109 1.92288069838009 1.92049880310668 1.91810496199492 1.91569927415240 1.91328183818251 1.91085275218661 1.90841211376627 1.90596002002548 1.90349656757275 1.90102185252339 1.89853597050162 1.89603901664270 1.89353108559514 1.89101227152279 1.88848266810698 1.88594236854864 1.88339146557039 1.88083005141866 1.87825821786576 1.87567605621199 1.87308365728765 1.87048111145519 1.86786850861116 1.86524593818833 1.86261348915771 1.85997125003053 1.85731930886031 1.85465775324484 1.85198667032819 1.84930614680269 1.84661626891091 1.84391712244766 1.84120879276190 1.83849136475875 1.83576492290140 1.83302955121309 1.83028533327899 1.82753235224814 1.82477069083540 1.82200043132329 1.81922165556395 1.81643444498099 1.81363888057138 1.81083504290734 1.80802301213817 1.80520286799215 1.80237468977836 1.79953855638852 1.79669454629885 1.79384273757188 1.79098320785825 1.78811603439854 1.78524129402510 1.78235906316378 1.77946941783578 1.77657243365938 1.77366818585177 1.77075674923075 1.76783819821655 1.76491260683352 1.76198004871193 1.75904059708966 1.75609432481398 1.75314130434320 1.75018160774846 1.74721530671537 1.74424247254577 1.74126317615938 1.73827748809551 1.73528547851471 1.73228721720050 1.72928277356095 1.72627221663041 1.72325561507115 1.72023303717496 1.71720455086485 1.71417022369661 1.71113012286052 1.70808431518289 1.70503286712770 1.70197584479823 1.69891331393861 1.69584533993546 1.69277198781941 1.68969332226677 1.68660940760100 1.68352030779434 1.68042608646938 1.67732680690054 1.67422253201569 1.67111332439765 1.66799924628574 1.66488035957729 1.66175672582918 1.65862840625934 1.65549546174827 1.65235795284053 1.64921593974624 1.64606948234258 1.64291864017527 1.63976347246002 1.63660403808406 1.63344039560754 1.63027260326505 1.62710071896701 1.62392480030119 1.62074490453409 1.61756108861240 1.61437340916446 1.61118192250163 1.60798668461974 1.60478775120050 1.60158517761291 1.59837901891464 1.59516932985347 1.59195616486864 1.58873957809224 1.58551962335059 1.58229635416566 1.57906982375634 1.57584008503991 1.57260719063331 1.56937119285456 1.56613214372404 1.56289009496590 1.55964509800932 1.55639720398990 1.55314646375097 1.54989292784488 1.54663664653434 1.54337766979374 1.54011604731041 1.53685182848594 1.53358506243751 1.53031579799910 1.52704408372284 1.52376996788025 1.52049349846351 1.51721472318676 1.51393368948733 1.51065044452699 1.50736503519323 1.50407750810048 1.50078790959138 1.49749628573799 1.49420268234301 1.49090714494105 1.48760971879982 1.48431044892133 1.48100938004314 1.47770655663956 1.47440202292281 1.47109582284426 1.46778800009561 1.46447859811008 1.46116766006355 1.45785522887583 1.45454134721172 1.45122605748225 1.44790940184585 1.44459142220945 1.44127216022968 1.43795165731401 1.43462995462187 1.43130709306582 1.42798311331269 1.42465805578467 1.42133196066046 1.41800486787641 1.41467681712758 1.41134784786894 1.40801799931637 1.40468731044786 1.40135582000454 1.39802356649183 1.39469058818047 1.39135692310765 1.38802260907807 1.38468768366504 1.38135218421152 1.37801614783119 1.37467961140955 1.37134261160493 1.36800518484960 1.36466736735075 1.36132919509161 1.35799070383243 1.35465192911156 1.35131290624645 1.34797367033472 1.34463425625514 1.34129469866868 1.33795503201952 1.33461529053606 1.33127550823193 1.32793571890697 1.32459595614830 1.32125625333121 1.31791664362027 1.31457715997020 1.31123783512696 1.30789870162865 1.30455979180654 1.30122113778599 1.29788277148748 1.29454472462753 1.29120702871964 1.28786971507532 1.28453281480497 1.28119635881886 1.27786037782809 1.27452490234548 1.27118996268656 1.26785558897046 1.26452181112088 1.26118865886698 1.25785616174431 1.25452434909574 1.25119325007237 1.24786289363441 1.24453330855215 1.24120452340678 1.23787656659136 1.23454946631169 1.23122325058718 1.22789794725176 1.22457358395477 1.22125018816181 1.21792778715567 1.21460640803712 1.21128607772588 1.20796682296139 1.20464867030376 1.20133164613454 1.19801577665766 1.19470108790021 1.19138760571334 1.18807535577308 1.18476436358118 1.18145465446596 1.17814625358312 1.17483918591663 1.17153347627945 1.16822914931448 1.16492622949528 1.16162474112694 1.15832470834688 1.15502615512566 1.15172910526776 1.14843358241246 1.14513961003454 1.14184721144515 1.13855640979258 1.13526722806305 1.13197968908148 1.12869381551230 1.12540962986023 1.12212715447104 1.11884641153231 1.11556742307426 1.11229021097045 1.10901479693858 1.10574120254124 1.10246944918668 1.09919955812955 1.09593155047166 1.09266544716271 1.08940126900108 1.08613903663452 1.08287877056091 1.07962049112901 1.07636421853917 1.07310997284407 1.06985777394945 1.06660764161482 1.06335959545421 1.06011365493683 1.05686983938786 1.05362816798911 1.05038865977972 1.04715133365691 1.04391620837666 1.04068330255439 1.03745263466568 1.03422422304698 1.03099808589625 1.02777424127369 1.02455270710241 1.02133350116911 1.01811664112476 1.01490214448529 1.01169002863224 1.00848031081345 1.00527300814371 1.00206813760545 0.998865716049361 0.995665760195108 0.992468286631939 0.989273311819364 0.986080852087796 0.982890923639205 0.979703542547760 0.976518724760467 0.973336486097822 0.970156842254431 0.966979808799657 0.963805401178249 0.960633634710965 0.957464524595207 0.954298085905637 0.951134333594803 0.947973282493756 0.944814947312659 0.941659342641416 0.938506482950264 0.935356382590394 0.932209055794548 0.929064516677626 0.925922779237284 0.922783857354535 0.919647764794513 0.916514553007848 0.913626501586297 0.957181910437377 1.18507611517074];
Ri=z_diff./cos(beta);
screens = zeros(Nx,Nx,length(F)-1);
for i = 2:length(F)
x = x + z_diff(i)*tan(beta);
screens(:,:,i)= screens(:, :, i-1) + exp(1i*((Kx.*x)+(Ky.*y))).*delfx.*delfy.*sqrt(F(i)).*R;
Hi = exp(1i*Kz*Ri(i) – c(i).*Ri(i));
Ui = fftshift(fft2(Uout));
Ui = Hi.*Ui;
Ui = ifft2(ifftshift(Ui));
Uio = Ui.*exp(1i.*screens(:,:,i));
I = Uio.*conj(Uio);
Uout = Uio;
end
% to calculate SigmaI
A1=0;A2=0;
for i1=1:Nx
for i2=1:Nx
I1 = I(i1,i2)^2 ;
A1 = A1 + I1 ;
end
end
for j1=1:Nx
for j2=1:Nx
I2 = I(j1,j2) ;
A2 = A2 + I2;
end
end
SI = abs(((A1/Nx)/((A2/Nx)^2)) – 1);
%to calculate BER
syms u
PI = (1/(u*sqrt(2*pi*SI)))*exp(-((log(u) + SI )^2)/(2*SI)) ;
SNR0 = 1;
SNR = SNR0/sqrt(1+SI*SNR0) ;
fun = PI*erfc(real((SNR.*u)/(2*sqrt(2))));
ff = matlabFunction(fun,’Vars’,u);
BER = (0.5*integral(ff,0,Inf))I need to calculate a parameter called SigmaI and BER, where the equation is
Here I is a 512*512 matrix. But the value of SigmaI that I calculated is not same as reported values.I think there is some error in writing the code. Also I need to calculate SigmaI for each F points (F is 1*757 matrix), but what I get is the value of SigmaI at the last point of F only. i.e, I need to generated SigmaI as 1*757 matrix. I am confused how to include it in the for loop. Similary BER also needed as a 1*757 matrix. Can anyone help me to get the right answer. The code is as follows,
clc;close all;clear all;
lambda = 532;
k = 2*pi/lambda;
z=linspace(1,757,757);
z_diff = (diff(z)) ;
z_diff = [0 z_diff];
tilt_angle=10;
beta=(pi/180)*tilt_angle;
Lx = 0.1;
Ly = Lx;
Nx = 512;
Ny = Nx ;
dx = Lx/Nx;
dy = Ly/Ny;
x = (-Nx/2:Nx/2-1)*dx;
y = (-Ny/2:Ny/2-1)*dy;
[X,Y] = meshgrid(x,y);
r = sqrt(X.^2 + Y.^2);
kx = meshgrid(-Nx/2:Nx/2-1)/(Nx.*dx);
ky = meshgrid(-Ny/2:Ny/2-1)/(Ny.*dy);
kz = ones(Nx);
Kx=cos(beta).*kx + sin(beta).*kz;
Ky=ky;
Kz=-sin(beta).*kx + cos(beta).*kz;
K2 = Kx.^2 + Ky.^2 + Kz.^2;
delfx = 1/(Lx);
delfy = delfx;
R = randn(Nx,Ny) ;
R = R – mean(R(:,:));
R = R/std(R(:,:));
Phi = [2.50310494762771e-07 2.50946965543003e-07 4.74127533715154e-07 5.24210357233832e-06 2.42362427581638e-07 1.42653443399616e-07 5.16930235276850e-07 9.04590700562310e-07 2.29541191637123e-06 3.60105794008093e-07 9.17845719860523e-08 2.50390367004531e-07 1.09738615765455e-06 1.00311041468925e-06 6.50810613011221e-08 3.02640252523566e-07 5.31047019902531e-07 1.80313245178286e-06 3.04099822876624e-06 1.47008194185741e-07 4.08290582950848e-08 3.82118426499270e-06 5.29334397036188e-07 4.87810778598663e-06 1.18782521297988e-06 1.16666772914768e-06 1.69778706192608e-06 7.67426466736916e-06 5.27799451227444e-06 4.23216916272082e-07 2.66828750584071e-05 2.46205729358867e-06 2.80169965568206e-06 2.97378024567976e-07 2.21170607901861e-07 3.41285818450589e-07 3.85275104621375e-08 4.05141179263807e-07 1.17629321652161e-06 4.95233464403551e-06 1.80125151270180e-06 2.81483058944610e-07 1.24528365857859e-05 6.86781782456521e-06 2.95828059847895e-06 1.27035361174474e-06 6.34388599513081e-07 2.32012818083199e-06 2.81784487117724e-06 1.46096455213802e-06 1.60178082889894e-06 1.94791694377124e-07 6.35459501021705e-08 8.30940388112504e-08 2.53354933929590e-07 4.31247522543152e-06 9.63180625859285e-07 8.03726503455623e-07 2.98282116276067e-07 9.25402679823575e-08 1.61856374619784e-07 1.73242501417858e-07 2.31570160754109e-07 1.78600321810053e-07 1.25598618058698e-07 1.63418364388577e-06 1.02774042441542e-06 8.32018926678718e-08 2.53586554087675e-07 2.53508325030189e-07 4.07413642129177e-08 2.42096085408459e-07 5.91587468209778e-07 1.27761778023523e-07 1.65773731666773e-07 1.79565395840267e-07 3.78521468221561e-07 1.21471607158554e-07 3.25378687175317e-07 1.25569084575180e-07 5.49035746100893e-08 4.07733632799329e-08 4.79103771763424e-07 3.27135102365317e-07 2.10496092551324e-07 1.33641668807187e-06 1.68227872575447e-06 1.52265748820018e-06 2.53683706505161e-07 1.25630494723704e-07 1.12347756326375e-06 2.53692684133802e-07 2.10500428113819e-07 2.52934873659000e-07 6.77249701528946e-07 2.95386782896753e-07 3.16617852613830e-07 3.59879226900604e-07 2.81244834536819e-07 2.35438339516804e-07 3.40806542459708e-07 6.44683615098099e-08 5.05945401350734e-07 2.57387924440325e-07 7.82108421793457e-08 2.52513556939930e-07 7.41154472489689e-08 8.95664707278605e-08 3.44823854262242e-07 2.57498619329261e-07 2.07939465354519e-06 7.18570183290631e-07 3.25198024230522e-07 2.11933525065655e-07 8.30783371984955e-08 1.65710628194624e-07 5.48396993890243e-08 5.95342783012939e-08 2.28819020334242e-07 1.99067722101735e-07 2.40425372248607e-07 2.51916559208949e-07 2.98446361528618e-07 2.82958505602994e-07 2.10599141757522e-07 4.60997674322361e-08 2.59856693650578e-07 1.47642122461920e-07 3.93574284250877e-07 3.94729289526600e-08 6.37347851352551e-08 2.51536627057736e-07 2.28438571372065e-07 1.90144303446780e-07 4.73626330414131e-08 6.44142268235402e-08 1.72106272576708e-06 1.70721924857358e-06 2.94643811973548e-07 3.55943119776846e-08 9.36518317402136e-08 4.31201179335937e-08 1.56428758776995e-07 3.19975996745435e-07 3.34275554966361e-07 1.20064760586921e-06 4.30984033789707e-07 2.15616245567332e-07 3.03074660779611e-07 3.29934827134432e-07 -2.24864187842034e-08 2.33412514429474e-07 3.21092520408291e-07 3.38617740923693e-07 6.04579881670076e-07 1.91481555229955e-07 9.38472397526705e-08 6.13052684855612e-07 3.97260343618278e-06 2.45355935394897e-07 3.47585309986832e-07 3.38923893338132e-07 2.20926360286704e-07 5.25446559955282e-07 2.84158336921376e-07 4.04755442008443e-07 3.35541338245773e-07 3.76856346223440e-07 2.75568777774655e-07 2.09025928742013e-07 7.10170870233622e-08 2.95787195332815e-07 5.59078661720798e-07 2.51150081156080e-07 4.02707325242296e-08 8.24148001852386e-08 2.57363940284162e-07 3.55816103375846e-07 3.95777597622744e-07 3.27993323594138e-07 3.52690891300866e-07 3.52278318886910e-07 5.06712192595194e-08 1.23808524289852e-07 8.39347385990663e-07 2.02892942754780e-07 7.97641133582245e-08 3.64530615247902e-07 9.11185642215493e-07 2.44511041473120e-07 3.24963966176285e-07 1.11685979674259e-07 2.86261990645848e-07 3.75634147009314e-08 2.16925989302430e-07 3.84116828662608e-07 2.71791109589261e-07 1.06845659312697e-07 2.02225581949648e-07 3.02535099485185e-07 3.11957552477906e-08 9.15881915538412e-08 9.18891121954120e-07 3.70106500980225e-07 2.25779726927071e-07 2.86067288473873e-07 5.66382866246259e-07 4.26632108086086e-07 4.53045634671475e-07 1.17973378714372e-06 3.40969918417227e-07 2.48643473538260e-07 2.64505922988546e-07 2.38444406096982e-07 3.47101823144428e-07 3.37625374999722e-07 3.20790426924069e-07 5.02178252920690e-08 1.73576015527609e-07 8.57402376593969e-07 1.80131811857122e-07 2.76964595681315e-07 2.14838038341036e-07 2.21053263051776e-07 1.59406260405821e-07 4.59614264881235e-08 3.78789455759776e-07 2.58966590318316e-07 7.75696011578299e-08 3.39990416320565e-07 3.24572509489827e-07 3.52020828992088e-08 6.49912862168267e-08 2.22828739301052e-07 2.13473046057573e-07 1.70720547021041e-07 2.19582224668132e-07 2.05914598785446e-07 1.14899310738254e-06 1.03415047080757e-07 1.89177690522258e-06 2.24175047702725e-07 3.76150153666139e-07 9.18124634120261e-08 2.27678254839140e-07 8.61346207114181e-08 3.38947999645138e-06 1.71880093129416e-07 2.22461873169689e-07 3.72427593494344e-08 6.76102058093114e-08 1.13163515787091e-06 7.04052219453715e-07 3.28310827940334e-07 2.12060821359437e-07 2.68576701610855e-07 2.04744061114503e-07 1.14622616867334e-07 4.35675529886048e-08 5.29665131717990e-08 3.50574437154752e-08 5.32920831968263e-08 1.04801149974382e-07 2.08316009852988e-07 2.77349913208742e-07 1.48756450473382e-07 3.78517042358300e-07 1.19222278136494e-07 4.57902170141890e-08 2.03249187200450e-07 9.32437812713631e-08 6.61503340988668e-07 1.01572927594225e-06 3.26294032932256e-07 2.26313604682662e-07 7.01012285236915e-08 7.61666326540900e-08 4.16954886967803e-08 4.41719683698357e-08 4.02549730011751e-08 4.41603434482274e-08 3.50371730851861e-08 3.00718061774876e-07 3.50372423542925e-08 5.32741630316562e-08 2.09046711312522e-07 3.75611845531339e-06 2.26535469768828e-07 4.62710159517236e-07 5.55357457448765e-07 4.16702305525217e-07 2.05922476618442e-07 2.06490274401431e-07 2.33754328058605e-07 1.66615319203810e-07 2.13390792614979e-07 2.54792444311713e-07 4.20241426628409e-07 6.95047952441784e-07 6.02254152247896e-07 1.56218004764843e-07 1.99836446669293e-07 1.62974708502310e-07 2.93420921132526e-07 1.67909832369442e-07 1.53692619622575e-07 8.89709805825161e-08 1.64148574413349e-07 1.82871518257336e-07 1.99566615308843e-07 1.59784291140960e-07 1.87893662090374e-07 2.77364481028229e-07 1.10443572547260e-07 2.18556580353372e-07 1.83932131011210e-07 7.94652011731045e-08 2.43919458395486e-07 1.59781205439559e-07 1.94642054497664e-07 1.29989372686070e-07 1.90910393259075e-07 2.84452061601644e-07 3.30006526167654e-07 1.93485493531741e-07 2.40209860863182e-07 4.15333943239071e-07 2.91343651778087e-07 2.58377576473351e-07 1.81274762632482e-07 1.88893039486970e-07 2.19428417763272e-07 2.20994023873646e-07 2.27950728874121e-07 1.64400439994395e-07 1.00341668297253e-07 1.67577483763212e-07 5.61980802260245e-08 3.04539633123467e-08 3.19018898206730e-08 3.89504322796163e-08 3.19941498021468e-07 5.41874921040340e-06 1.01776790218898e-06 1.29079721421378e-06 5.77887058141474e-07 2.79939362285509e-07 5.55989804582382e-08 2.11144624551603e-07 5.73140726411827e-08 5.35992572193921e-08 2.80066251579433e-07 1.76964657359828e-07 3.25199602895421e-07 2.18271466195228e-07 1.80628024038326e-07 4.69550563668357e-08 1.48055689005769e-07 1.82317859358405e-07 1.33063533148151e-07 2.62672490298873e-08 2.52416541944235e-08 2.08244390466210e-07 3.06261128674104e-07 2.18183988930487e-07 1.32114003617060e-07 3.13731744862144e-07 2.78980205382911e-07 2.42110700965470e-08 1.28818767334643e-07 3.48416502648141e-07 1.43250842379859e-07 2.58790299254369e-08 2.36803673262810e-08 2.54679999490770e-08 1.53423624973069e-07 2.11044574009824e-07 2.45219073821534e-08 5.40329423903049e-08 4.07828910547019e-08 2.86866659397290e-08 5.74108869690081e-08 3.17780519921456e-08 2.89072270765441e-07 6.46668413187508e-08 3.89801393203052e-07 1.62322978572959e-07 2.69026419637955e-07 4.76120100475985e-07 5.32185045407108e-07 1.57575408820348e-07 2.08858600548085e-07 1.87565977660685e-07 2.01108310997773e-07 3.95620143987532e-08 5.24866345380986e-08 8.64930520826212e-08 9.74072997804584e-07 2.54439638933078e-08 1.00154777975012e-07 9.42429455464106e-07 2.23088555779751e-07 2.02097796370716e-07 1.99163165408265e-07 9.26536634692885e-08 1.31298738607173e-07 1.97726692783641e-07 2.28150683478771e-07 2.17170907865184e-07 2.69677497220439e-08 1.54765400027711e-07 6.26255760215395e-08 1.46771827369792e-07 1.81515822529873e-07 1.72918459779846e-07 8.15990146285526e-08 9.85514009220808e-08 7.03396855430348e-07 5.93657045438661e-07 1.51834395684521e-07 9.76927764035926e-08 1.18527867299870e-07 2.71435324116586e-08 5.68571003566081e-08 1.65983256102705e-07 2.29129793972797e-07 5.88646431511064e-08 3.08684402204026e-05 2.38265317337181e-06 4.30752744717656e-07 1.04689461805175e-07 2.32270648752108e-07 6.07211466407868e-07 1.95341105985221e-08 7.38231690963101e-08 1.95129857199575e-07 4.01671898332107e-08 4.75072551754564e-08 2.49046064060719e-06 1.78142428447807e-07 2.60935684174315e-07 4.29594269700864e-08 1.14070714922750e-07 5.26390027271695e-08 6.74132420131039e-08 2.11045265009953e-07 7.27021148761358e-07 2.83886081059763e-07 2.76343292567963e-08 1.61294742863238e-07 1.83304573271511e-07 2.45251911632262e-07 9.18095053702886e-07 9.40457085677553e-07 2.90451584499496e-07 1.04003175628026e-07 1.08284695915254e-07 5.44402482199441e-08 2.02578013696944e-08 5.88615942025308e-08 1.04406254724335e-07 1.20598226687063e-07 5.71264670628078e-07 3.15144191075623e-07 2.23052176438872e-08 2.98936409995515e-08 2.92428609360162e-07 2.47505388371339e-07 2.72866577624107e-07 2.69881858030521e-07 1.85519336468060e-07 2.56402576998181e-07 8.88653855726949e-08 1.23281438816645e-07 3.74059740200056e-08 3.63466577344003e-08 1.20887062612203e-06 5.31728280982040e-07 2.22245937870703e-08 1.24471844746278e-07 5.11735373064063e-07 3.13008213548308e-07 5.70247343660301e-08 7.23194564373494e-07 1.79616235944090e-07 6.78737172874271e-08 1.87999018332358e-07 1.56051038058590e-07 2.31029093824182e-08 3.65957708093627e-08 5.13581582166058e-07 2.55008648105981e-08 1.44166238137747e-07 3.81609462756446e-07 2.16242665285891e-07 2.34087134829968e-07 2.55408939395098e-07 5.31844204547311e-08 1.37230800917903e-07 2.24923680386313e-07 7.91242025449375e-08 1.56574476334133e-07 1.34926252415438e-07 1.70013819330808e-08 1.48130847036606e-07 1.10651211565701e-07 1.58123074045499e-07 1.47865663105776e-07 1.14316450201195e-07 2.02955526741989e-08 1.49518466142608e-07 2.99469635848321e-08 4.06175629714119e-07 2.32871553385763e-07 1.70948094081342e-07 1.86984334344187e-07 1.54774299548728e-07 1.27005955203776e-07 7.29605614875902e-08 4.26639317987837e-08 5.91930531596668e-08 1.50666658228087e-08 4.86748534643297e-08 1.64538615062307e-08 1.32252962938291e-07 1.06729078335828e-07 1.39785078669013e-07 1.39779800669610e-07 9.26422941859900e-08 1.13233915195479e-07 8.32946711657419e-08 1.67451405167575e-07 3.65621117891888e-08 2.21661117907828e-07 3.65652178907218e-08 1.41441861581090e-06 3.30075312403152e-07 2.05346680636497e-08 2.16432978289422e-07 1.92694668921994e-07 1.99379501668891e-07 2.60904461669433e-07 2.16709099204294e-07 1.33136064843243e-07 1.52413473502972e-07 7.53889226907776e-07 3.22036453180506e-07 1.68931528429636e-07 1.04094510285934e-07 1.60098934336117e-07 1.02657996503878e-07 6.83661821001145e-08 1.61931255758191e-07 2.01320024686194e-07 1.07534006069169e-07 1.07910634894973e-07 9.46522813533042e-08 1.66743437525985e-07 1.78365196465516e-07 1.90349497426267e-07 1.99051143944893e-07 1.10969246755729e-07 1.11264782143939e-07 1.02006294022338e-07 1.24767050443006e-07 1.04932154146443e-07 1.03659587531759e-07 4.90478970104965e-08 9.01107885624077e-08 9.30802687007756e-08 2.06842405795697e-07 1.53448550376276e-07 9.79061221486547e-08 8.26140384317179e-08 1.50146254483116e-07 1.40136146748372e-07 1.56837338087257e-07 1.76198808159403e-07 1.99122966368083e-07 1.23858764266714e-07 1.06727895602262e-07 8.15204687804434e-08 1.88227798887152e-08 2.31668781894091e-08 7.67325491571661e-07 1.97158231154847e-07 1.04232262587474e-07 8.81089549804027e-09 1.09695696650620e-08 3.67828021042941e-07 2.42873900856430e-07 9.30400519863338e-08 1.22815336391232e-08 1.04498084973760e-07 4.13726864269242e-07 1.28584375991528e-08 1.20376581165868e-07 1.07046398186240e-07 5.96207309583810e-08 3.66763563633301e-08 1.21422552113772e-07 1.39822102904246e-07 1.58475758239753e-07 8.54716186106630e-08 9.47107273229749e-08 1.57282457487923e-07 2.22341833330773e-07 1.47297286955243e-07 2.19435143761748e-07 1.39688617089499e-07 7.24259126481027e-08 7.09641458863346e-08 1.19226547380480e-07 7.87372467318109e-08 9.72314598010880e-08 7.74647075656411e-09 9.47412998435404e-08 1.16751285273194e-07 1.13487779361823e-07 1.13827758524977e-07 2.72522446715463e-07 8.16170870703966e-08 8.72321297381038e-08 9.95784392252335e-08 2.65989252708394e-09 1.06630932742284e-07 9.36921419305549e-08 8.41656329617571e-08 1.30269792124746e-08 4.86904164038956e-06 1.01469686899418e-07 1.47172552045969e-07 1.11949067863535e-07 9.34802107168088e-08 6.41098286680338e-08 6.68095594366830e-09 4.65659962399765e-08 1.74321722504626e-07 1.53177157686198e-07 1.72679939394816e-07 9.26791009109865e-08 7.38280843033631e-09 1.21431764801520e-08 1.83474589517062e-08 5.49758746890643e-08 5.49686356365556e-08 5.41396143667257e-07 1.02078716839878e-08 1.46280082306786e-07 9.20039209747377e-08 1.07464173701763e-08 4.37249887631680e-08 1.20696543908951e-07 7.37023067237918e-08 1.54370995646110e-07 8.75880053587604e-08 1.38972473988507e-07 1.50011697718075e-07 1.13900910702895e-07 7.30960487245964e-08 1.06352204500379e-07 7.15892552073097e-09 1.26382007766409e-08 2.34492999966371e-07 9.25652500580458e-08 8.91104525001921e-08 1.04346566674604e-08 7.96833204055166e-08 3.41626685510968e-07 1.46859973263572e-07 6.99097620123092e-08 5.60565018753087e-08 9.18716519344181e-08 5.82078430390537e-09 8.51757309259611e-08 1.41028716092150e-07 7.10210717526897e-09 3.02205722277794e-08 2.76205242367368e-07 9.08403872147274e-08 8.55641175181640e-08 8.07674139440669e-08 5.64950026938399e-09 1.47871928050032e-07 1.37623718221666e-07 9.60980796219824e-08 9.05395061229061e-09 3.58713661087815e-07 3.78246981154481e-07 1.97627162656081e-08 4.78463482905684e-08 5.47976120635378e-07 5.98012738422856e-07 1.38288635243591e-07 3.97209746106909e-08 1.04405402152745e-07 1.64230983323839e-08 2.14721179480984e-08 4.85083210883807e-08 1.22646011220379e-06 8.39456826640735e-09 8.27662116573820e-08 3.58891263221149e-07 9.16048888640066e-08 1.21278839928491e-07 2.31054125718236e-07 1.00889365297461e-07 1.19358834432565e-07 2.43427211256917e-07 9.11020950715102e-08 1.38162844699562e-07 8.00915682468241e-08 4.98258405386454e-09 7.30080219716715e-08 1.52701681888474e-07 2.93328698184570e-07 1.35353313498113e-07 4.59682925254202e-08 9.08782411223864e-08 2.20927979357592e-08 9.05503229704100e-08 6.68343694641667e-08 7.33025736057753e-08 7.49958147508063e-08 6.22824091009223e-09 8.02682015058001e-06 3.67877032868707e-07 7.19496678750717e-08 3.17758490462365e-09 5.75563157661276e-09 3.24272951280416e-09 1.00381201383279e-07 1.88260239049035e-07 7.07194739983604e-08 4.68947848174950e-09 4.16252458503278e-09 7.94576959843098e-08 2.74009776209153e-07 1.42430916804990e-07 1.26235913248699e-07 1.39626029880374e-07 1.16782761195100e-07 1.00256563902946e-07 -2.95101260456139e-09 6.83432403678117e-08 1.27348806727558e-07 5.96766339731236e-08 1.03604721020808e-07 1.21085249476580e-07 6.80561072346092e-08 2.39948064835149e-09 1.00688731186191e-08 2.43035685127838e-08 4.13254891501583e-08 9.63544005596039e-09 2.53883818143423e-07 7.44890597640385e-07];
w0=0.002;
F=2*(pi^2)*(k^2).*z_diff.*Phi;
x0 = linspace(-0.02,0.02,Nx);y0=x0;[X0,Y0] = meshgrid(x0,y0);
Uin=exp(-(X0.^2+Y0.^2)/w0^2);
x = x + z_diff(1)*tan(beta);
screen1 = exp(1i*((Kx.*x) + (Ky.*y))).*delfx.*delfy.*sqrt(F(1)).*R ;
Uout = Uin.*exp(1i.*screen1);
c=[0.740664357812470 0.715162315217582 0.689780546528124 0.664556687838984 0.639501229779350 0.614618312979130 0.589909677254809 0.565375929219662 0.541017064806704 0.516832720551119 0.492822307973243 0.468985091286926 0.445320235117717 0.421826835235231 0.398503939126698 0.375350560217132 0.352365687964806 0.329548295192595 0.306897343515746 0.284411787427262 0.262090577416753 0.239932662380474 0.217936991503006 0.196102515739251 0.174428188990141 0.152912969040777 0.131555818312352 0.110355704466664 0.0893116008928944 0.0684224870996102 0.0476873490298864 0.0271051793136574 0.00667497746850089 0.0136042499421828 0.0337334891863653 0.0537137192700918 0.0735459118688980 0.0932310312800026 0.112770034392025 0.132163870669524 0.151413482150099 0.170519803452171 0.189483761791847 0.208306277007520 0.226988261591059 0.245530620724636 0.263934252322323 0.282200047075789 0.300328888503445 0.318321653002534 0.336179209903699 0.353902421527639 0.371492143243500 0.388949223528713 0.406274504030009 0.423468819625392 0.440532998486862 0.457467862143721 0.474274225546305 0.490952897130006 0.507504678879476 0.523930366392895 0.540230748946220 0.556406609557339 0.572458725050048 0.588387866117797 0.604194797387153 0.619880277480917 0.635445059080876 0.650889888990134 0.666215508194993 0.681422651926368 0.696512049720699 0.711484425480339 0.726340497533411 0.741080978693105 0.755706576316408 0.770217992362264 0.784615923449129 0.798901060911951 0.813074090858528 0.827135694225279 0.841086546832386 0.854927319438336 0.868658677793846 0.882281282695167 0.895795790036781 0.909202850863477 0.922503111421817 0.935697213210995 0.948785793033077 0.961769483042646 0.974648910795838 0.987424699298783 1.00009746705545 1.01266782811491 1.02513639211797 1.03750376434332 1.04977054575300 1.06193733303735 1.07400471865938 1.08597329089862 1.09784363389434 1.10961632768826 1.12129194826677 1.13287106760249 1.14435425369543 1.15574207061353 1.16703507853271 1.17823383377643 1.18933888885472 1.20035079250267 1.21127008971854 1.22209732180122 1.23283302638735 1.24347773748787 1.25403198552414 1.26449629736359 1.27487119635488 1.28515720236266 1.29535483180181 1.30546459767133 1.31548700958769 1.32542257381781 1.33527179331163 1.34503516773420 1.35471319349739 1.36430636379121 1.37381516861470 1.38324009480640 1.39258162607448 1.40184024302645 1.41101642319850 1.42011064108442 1.42912336816425 1.43805507293243 1.44690622092571 1.45567727475060 1.46436869411057 1.47298093583279 1.48151445389465 1.48996969944983 1.49834712085410 1.50664716369079 1.51487027079592 1.52301688228302 1.53108743556759 1.53908236539135 1.54700210384610 1.55484708039729 1.56261772190731 1.57031445265850 1.57793769437581 1.58548786624928 1.59296538495611 1.60037066468257 1.60770411714556 1.61496615161393 1.62215717492952 1.62927759152798 1.63632780345927 1.64330821040796 1.65021920971321 1.65706119638862 1.66383456314170 1.67053970039319 1.67717699629614 1.68374683675467 1.69024960544263 1.69668568382193 1.70305545116068 1.70935928455115 1.71559755892740 1.72177064708287 1.72787891968756 1.73392274530517 1.73990249040993 1.74581851940328 1.75167119463032 1.75746087639608 1.76318792298160 1.76885269065981 1.77445553371120 1.77999680443936 1.78547685318630 1.79089602834756 1.79625467638721 1.80155314185264 1.80679176738913 1.81197089375438 1.81709085983270 1.82215200264920 1.82715465738367 1.83209915738443 1.83698583418192 1.84181501750219 1.84658703528021 1.85130221367304 1.85596087707287 1.86056334811985 1.86510994771484 1.86960099503199 1.87403680753115 1.87841770097023 1.88274398941727 1.88701598526258 1.89123399923051 1.89539834039132 1.89950931617273 1.90356723237146 1.90757239316461 1.91152510112087 1.91542565721170 1.91927436082231 1.92307150976254 1.92681740027765 1.93051232705897 1.93415658325440 1.93775046047891 1.94129424882478 1.94478823687186 1.94823271169764 1.95162795888723 1.95497426254328 1.95827190529575 1.96152116831153 1.96472233130413 1.96787567254306 1.97098146886325 1.97403999567435 1.97705152696986 1.98001633533631 1.98293469196218 1.98580686664685 1.98863312780943 1.99141374249746 1.99414897639556 1.99683909383401 1.99948435779718 2.00208502993198 2.00464137055607 2.00715363866619 2.00962209194621 2.01204698677524 2.01442857823560 2.01676712012071 2.01906286494297 2.02131606394144 2.02352696708957 2.02569582310279 2.02782287944605 2.02990838234126 2.03195257677470 2.03395570650435 2.03591801406711 2.03783974078601 2.03972112677735 2.04156241095768 2.04336383105087 2.04512562359498 2.04684802394913 2.04853126630031 2.05017558367013 2.05178120792145 2.05334836976503 2.05487729876606 2.05636822335072 2.05782137081251 2.05923696731876 2.06061523791685 2.06195640654055 2.06326069601621 2.06452832806891 2.06575952332861 2.06695450133616 2.06811348054936 2.06923667834885 2.07032431104407 2.07137659387907 2.07239374103836 2.07337596565262 2.07432347980443 2.07523649453394 2.07611521984447 2.07695986470806 2.07777063707106 2.07854774385950 2.07929139098462 2.08000178334822 2.08067912484798 2.08132361838281 2.08193546585808 2.08251486819086 2.08306202531507 2.08357713618662 2.08406039878854 2.08451201013601 2.08493216628138 2.08532106231914 2.08567889239087 2.08600584969017 2.08630212646748 2.08656791403493 2.08680340277114 2.08700878212594 2.08718424062516 2.08732996587524 2.08744614456794 2.08753296248490 2.08759060450230 2.08761925459532 2.08761909584274 2.08759031043135 2.08753307966046 2.08744758394630 2.08733400282638 2.08719251496389 2.08702329815202 2.08682652931821 2.08660238452849 2.08635103899165 2.08607266706347 2.08576744225093 2.08543553721630 2.08507712378131 2.08469237293121 2.08428145481885 2.08384453876873 2.08338179328099 2.08289338603538 2.08237948389527 2.08184025291152 2.08127585832643 2.08068646457760 2.08007223530177 2.07943333333869 2.07876992073487 2.07808215874743 2.07737020784777 2.07663422772538 2.07587437729149 2.07509081468279 2.07428369726507 2.07345318163688 2.07259942363312 2.07172257832864 2.07082280004183 2.06990024233815 2.06895505803365 2.06798739919850 2.06699741716044 2.06598526250827 2.06495108509530 2.06389503404273 2.06281725774310 2.06171790386362 2.06059711934957 2.05945505042762 2.05829184260918 2.05710764069365 2.05590258877174 2.05467683022873 2.05343050774771 2.05216376331278 2.05087673821232 2.04956957304210 2.04824240770851 2.04689538143169 2.04552863274867 2.04414229951646 2.04273651891521 2.04131142745123 2.03986716096009 2.03840385460964 2.03692164290309 2.03542065968197 2.03390103812916 2.03236291077188 2.03080640948460 2.02923166549207 2.02763880937220 2.02602797105897 2.02439927984538 2.02275286438630 2.02108885270135 2.01940737217775 2.01770854957318 2.01599251101859 2.01425938202100 2.01250928746633 2.01074235162217 2.00895869814052 2.00715845006058 2.00534172981146 2.00350865921493 2.00165935948813 1.99979395124624 1.99791255450517 1.99601528868428 1.99410227260896 1.99217362451332 1.99022946204283 1.98826990225688 1.98629506163147 1.98430505606170 1.98230000086442 1.98028001078079 1.97824519997880 1.97619568205582 1.97413157004115 1.97205297639850 1.96996001302854 1.96785279127132 1.96573142190885 1.96359601516744 1.96144668072028 1.95928352768979 1.95710666465011 1.95491619962948 1.95271224011267 1.95049489304337 1.94826426482658 1.94602046133099 1.94376358789132 1.94149374931069 1.93921104986296 1.93691559329504 1.93460748282926 1.93228682116561 1.92995371048410 1.92760825244698 1.92525054820109 1.92288069838009 1.92049880310668 1.91810496199492 1.91569927415240 1.91328183818251 1.91085275218661 1.90841211376627 1.90596002002548 1.90349656757275 1.90102185252339 1.89853597050162 1.89603901664270 1.89353108559514 1.89101227152279 1.88848266810698 1.88594236854864 1.88339146557039 1.88083005141866 1.87825821786576 1.87567605621199 1.87308365728765 1.87048111145519 1.86786850861116 1.86524593818833 1.86261348915771 1.85997125003053 1.85731930886031 1.85465775324484 1.85198667032819 1.84930614680269 1.84661626891091 1.84391712244766 1.84120879276190 1.83849136475875 1.83576492290140 1.83302955121309 1.83028533327899 1.82753235224814 1.82477069083540 1.82200043132329 1.81922165556395 1.81643444498099 1.81363888057138 1.81083504290734 1.80802301213817 1.80520286799215 1.80237468977836 1.79953855638852 1.79669454629885 1.79384273757188 1.79098320785825 1.78811603439854 1.78524129402510 1.78235906316378 1.77946941783578 1.77657243365938 1.77366818585177 1.77075674923075 1.76783819821655 1.76491260683352 1.76198004871193 1.75904059708966 1.75609432481398 1.75314130434320 1.75018160774846 1.74721530671537 1.74424247254577 1.74126317615938 1.73827748809551 1.73528547851471 1.73228721720050 1.72928277356095 1.72627221663041 1.72325561507115 1.72023303717496 1.71720455086485 1.71417022369661 1.71113012286052 1.70808431518289 1.70503286712770 1.70197584479823 1.69891331393861 1.69584533993546 1.69277198781941 1.68969332226677 1.68660940760100 1.68352030779434 1.68042608646938 1.67732680690054 1.67422253201569 1.67111332439765 1.66799924628574 1.66488035957729 1.66175672582918 1.65862840625934 1.65549546174827 1.65235795284053 1.64921593974624 1.64606948234258 1.64291864017527 1.63976347246002 1.63660403808406 1.63344039560754 1.63027260326505 1.62710071896701 1.62392480030119 1.62074490453409 1.61756108861240 1.61437340916446 1.61118192250163 1.60798668461974 1.60478775120050 1.60158517761291 1.59837901891464 1.59516932985347 1.59195616486864 1.58873957809224 1.58551962335059 1.58229635416566 1.57906982375634 1.57584008503991 1.57260719063331 1.56937119285456 1.56613214372404 1.56289009496590 1.55964509800932 1.55639720398990 1.55314646375097 1.54989292784488 1.54663664653434 1.54337766979374 1.54011604731041 1.53685182848594 1.53358506243751 1.53031579799910 1.52704408372284 1.52376996788025 1.52049349846351 1.51721472318676 1.51393368948733 1.51065044452699 1.50736503519323 1.50407750810048 1.50078790959138 1.49749628573799 1.49420268234301 1.49090714494105 1.48760971879982 1.48431044892133 1.48100938004314 1.47770655663956 1.47440202292281 1.47109582284426 1.46778800009561 1.46447859811008 1.46116766006355 1.45785522887583 1.45454134721172 1.45122605748225 1.44790940184585 1.44459142220945 1.44127216022968 1.43795165731401 1.43462995462187 1.43130709306582 1.42798311331269 1.42465805578467 1.42133196066046 1.41800486787641 1.41467681712758 1.41134784786894 1.40801799931637 1.40468731044786 1.40135582000454 1.39802356649183 1.39469058818047 1.39135692310765 1.38802260907807 1.38468768366504 1.38135218421152 1.37801614783119 1.37467961140955 1.37134261160493 1.36800518484960 1.36466736735075 1.36132919509161 1.35799070383243 1.35465192911156 1.35131290624645 1.34797367033472 1.34463425625514 1.34129469866868 1.33795503201952 1.33461529053606 1.33127550823193 1.32793571890697 1.32459595614830 1.32125625333121 1.31791664362027 1.31457715997020 1.31123783512696 1.30789870162865 1.30455979180654 1.30122113778599 1.29788277148748 1.29454472462753 1.29120702871964 1.28786971507532 1.28453281480497 1.28119635881886 1.27786037782809 1.27452490234548 1.27118996268656 1.26785558897046 1.26452181112088 1.26118865886698 1.25785616174431 1.25452434909574 1.25119325007237 1.24786289363441 1.24453330855215 1.24120452340678 1.23787656659136 1.23454946631169 1.23122325058718 1.22789794725176 1.22457358395477 1.22125018816181 1.21792778715567 1.21460640803712 1.21128607772588 1.20796682296139 1.20464867030376 1.20133164613454 1.19801577665766 1.19470108790021 1.19138760571334 1.18807535577308 1.18476436358118 1.18145465446596 1.17814625358312 1.17483918591663 1.17153347627945 1.16822914931448 1.16492622949528 1.16162474112694 1.15832470834688 1.15502615512566 1.15172910526776 1.14843358241246 1.14513961003454 1.14184721144515 1.13855640979258 1.13526722806305 1.13197968908148 1.12869381551230 1.12540962986023 1.12212715447104 1.11884641153231 1.11556742307426 1.11229021097045 1.10901479693858 1.10574120254124 1.10246944918668 1.09919955812955 1.09593155047166 1.09266544716271 1.08940126900108 1.08613903663452 1.08287877056091 1.07962049112901 1.07636421853917 1.07310997284407 1.06985777394945 1.06660764161482 1.06335959545421 1.06011365493683 1.05686983938786 1.05362816798911 1.05038865977972 1.04715133365691 1.04391620837666 1.04068330255439 1.03745263466568 1.03422422304698 1.03099808589625 1.02777424127369 1.02455270710241 1.02133350116911 1.01811664112476 1.01490214448529 1.01169002863224 1.00848031081345 1.00527300814371 1.00206813760545 0.998865716049361 0.995665760195108 0.992468286631939 0.989273311819364 0.986080852087796 0.982890923639205 0.979703542547760 0.976518724760467 0.973336486097822 0.970156842254431 0.966979808799657 0.963805401178249 0.960633634710965 0.957464524595207 0.954298085905637 0.951134333594803 0.947973282493756 0.944814947312659 0.941659342641416 0.938506482950264 0.935356382590394 0.932209055794548 0.929064516677626 0.925922779237284 0.922783857354535 0.919647764794513 0.916514553007848 0.913626501586297 0.957181910437377 1.18507611517074];
Ri=z_diff./cos(beta);
screens = zeros(Nx,Nx,length(F)-1);
for i = 2:length(F)
x = x + z_diff(i)*tan(beta);
screens(:,:,i)= screens(:, :, i-1) + exp(1i*((Kx.*x)+(Ky.*y))).*delfx.*delfy.*sqrt(F(i)).*R;
Hi = exp(1i*Kz*Ri(i) – c(i).*Ri(i));
Ui = fftshift(fft2(Uout));
Ui = Hi.*Ui;
Ui = ifft2(ifftshift(Ui));
Uio = Ui.*exp(1i.*screens(:,:,i));
I = Uio.*conj(Uio);
Uout = Uio;
end
% to calculate SigmaI
A1=0;A2=0;
for i1=1:Nx
for i2=1:Nx
I1 = I(i1,i2)^2 ;
A1 = A1 + I1 ;
end
end
for j1=1:Nx
for j2=1:Nx
I2 = I(j1,j2) ;
A2 = A2 + I2;
end
end
SI = abs(((A1/Nx)/((A2/Nx)^2)) – 1);
%to calculate BER
syms u
PI = (1/(u*sqrt(2*pi*SI)))*exp(-((log(u) + SI )^2)/(2*SI)) ;
SNR0 = 1;
SNR = SNR0/sqrt(1+SI*SNR0) ;
fun = PI*erfc(real((SNR.*u)/(2*sqrt(2))));
ff = matlabFunction(fun,’Vars’,u);
BER = (0.5*integral(ff,0,Inf)) I need to calculate a parameter called SigmaI and BER, where the equation is
Here I is a 512*512 matrix. But the value of SigmaI that I calculated is not same as reported values.I think there is some error in writing the code. Also I need to calculate SigmaI for each F points (F is 1*757 matrix), but what I get is the value of SigmaI at the last point of F only. i.e, I need to generated SigmaI as 1*757 matrix. I am confused how to include it in the for loop. Similary BER also needed as a 1*757 matrix. Can anyone help me to get the right answer. The code is as follows,
clc;close all;clear all;
lambda = 532;
k = 2*pi/lambda;
z=linspace(1,757,757);
z_diff = (diff(z)) ;
z_diff = [0 z_diff];
tilt_angle=10;
beta=(pi/180)*tilt_angle;
Lx = 0.1;
Ly = Lx;
Nx = 512;
Ny = Nx ;
dx = Lx/Nx;
dy = Ly/Ny;
x = (-Nx/2:Nx/2-1)*dx;
y = (-Ny/2:Ny/2-1)*dy;
[X,Y] = meshgrid(x,y);
r = sqrt(X.^2 + Y.^2);
kx = meshgrid(-Nx/2:Nx/2-1)/(Nx.*dx);
ky = meshgrid(-Ny/2:Ny/2-1)/(Ny.*dy);
kz = ones(Nx);
Kx=cos(beta).*kx + sin(beta).*kz;
Ky=ky;
Kz=-sin(beta).*kx + cos(beta).*kz;
K2 = Kx.^2 + Ky.^2 + Kz.^2;
delfx = 1/(Lx);
delfy = delfx;
R = randn(Nx,Ny) ;
R = R – mean(R(:,:));
R = R/std(R(:,:));
Phi = [2.50310494762771e-07 2.50946965543003e-07 4.74127533715154e-07 5.24210357233832e-06 2.42362427581638e-07 1.42653443399616e-07 5.16930235276850e-07 9.04590700562310e-07 2.29541191637123e-06 3.60105794008093e-07 9.17845719860523e-08 2.50390367004531e-07 1.09738615765455e-06 1.00311041468925e-06 6.50810613011221e-08 3.02640252523566e-07 5.31047019902531e-07 1.80313245178286e-06 3.04099822876624e-06 1.47008194185741e-07 4.08290582950848e-08 3.82118426499270e-06 5.29334397036188e-07 4.87810778598663e-06 1.18782521297988e-06 1.16666772914768e-06 1.69778706192608e-06 7.67426466736916e-06 5.27799451227444e-06 4.23216916272082e-07 2.66828750584071e-05 2.46205729358867e-06 2.80169965568206e-06 2.97378024567976e-07 2.21170607901861e-07 3.41285818450589e-07 3.85275104621375e-08 4.05141179263807e-07 1.17629321652161e-06 4.95233464403551e-06 1.80125151270180e-06 2.81483058944610e-07 1.24528365857859e-05 6.86781782456521e-06 2.95828059847895e-06 1.27035361174474e-06 6.34388599513081e-07 2.32012818083199e-06 2.81784487117724e-06 1.46096455213802e-06 1.60178082889894e-06 1.94791694377124e-07 6.35459501021705e-08 8.30940388112504e-08 2.53354933929590e-07 4.31247522543152e-06 9.63180625859285e-07 8.03726503455623e-07 2.98282116276067e-07 9.25402679823575e-08 1.61856374619784e-07 1.73242501417858e-07 2.31570160754109e-07 1.78600321810053e-07 1.25598618058698e-07 1.63418364388577e-06 1.02774042441542e-06 8.32018926678718e-08 2.53586554087675e-07 2.53508325030189e-07 4.07413642129177e-08 2.42096085408459e-07 5.91587468209778e-07 1.27761778023523e-07 1.65773731666773e-07 1.79565395840267e-07 3.78521468221561e-07 1.21471607158554e-07 3.25378687175317e-07 1.25569084575180e-07 5.49035746100893e-08 4.07733632799329e-08 4.79103771763424e-07 3.27135102365317e-07 2.10496092551324e-07 1.33641668807187e-06 1.68227872575447e-06 1.52265748820018e-06 2.53683706505161e-07 1.25630494723704e-07 1.12347756326375e-06 2.53692684133802e-07 2.10500428113819e-07 2.52934873659000e-07 6.77249701528946e-07 2.95386782896753e-07 3.16617852613830e-07 3.59879226900604e-07 2.81244834536819e-07 2.35438339516804e-07 3.40806542459708e-07 6.44683615098099e-08 5.05945401350734e-07 2.57387924440325e-07 7.82108421793457e-08 2.52513556939930e-07 7.41154472489689e-08 8.95664707278605e-08 3.44823854262242e-07 2.57498619329261e-07 2.07939465354519e-06 7.18570183290631e-07 3.25198024230522e-07 2.11933525065655e-07 8.30783371984955e-08 1.65710628194624e-07 5.48396993890243e-08 5.95342783012939e-08 2.28819020334242e-07 1.99067722101735e-07 2.40425372248607e-07 2.51916559208949e-07 2.98446361528618e-07 2.82958505602994e-07 2.10599141757522e-07 4.60997674322361e-08 2.59856693650578e-07 1.47642122461920e-07 3.93574284250877e-07 3.94729289526600e-08 6.37347851352551e-08 2.51536627057736e-07 2.28438571372065e-07 1.90144303446780e-07 4.73626330414131e-08 6.44142268235402e-08 1.72106272576708e-06 1.70721924857358e-06 2.94643811973548e-07 3.55943119776846e-08 9.36518317402136e-08 4.31201179335937e-08 1.56428758776995e-07 3.19975996745435e-07 3.34275554966361e-07 1.20064760586921e-06 4.30984033789707e-07 2.15616245567332e-07 3.03074660779611e-07 3.29934827134432e-07 -2.24864187842034e-08 2.33412514429474e-07 3.21092520408291e-07 3.38617740923693e-07 6.04579881670076e-07 1.91481555229955e-07 9.38472397526705e-08 6.13052684855612e-07 3.97260343618278e-06 2.45355935394897e-07 3.47585309986832e-07 3.38923893338132e-07 2.20926360286704e-07 5.25446559955282e-07 2.84158336921376e-07 4.04755442008443e-07 3.35541338245773e-07 3.76856346223440e-07 2.75568777774655e-07 2.09025928742013e-07 7.10170870233622e-08 2.95787195332815e-07 5.59078661720798e-07 2.51150081156080e-07 4.02707325242296e-08 8.24148001852386e-08 2.57363940284162e-07 3.55816103375846e-07 3.95777597622744e-07 3.27993323594138e-07 3.52690891300866e-07 3.52278318886910e-07 5.06712192595194e-08 1.23808524289852e-07 8.39347385990663e-07 2.02892942754780e-07 7.97641133582245e-08 3.64530615247902e-07 9.11185642215493e-07 2.44511041473120e-07 3.24963966176285e-07 1.11685979674259e-07 2.86261990645848e-07 3.75634147009314e-08 2.16925989302430e-07 3.84116828662608e-07 2.71791109589261e-07 1.06845659312697e-07 2.02225581949648e-07 3.02535099485185e-07 3.11957552477906e-08 9.15881915538412e-08 9.18891121954120e-07 3.70106500980225e-07 2.25779726927071e-07 2.86067288473873e-07 5.66382866246259e-07 4.26632108086086e-07 4.53045634671475e-07 1.17973378714372e-06 3.40969918417227e-07 2.48643473538260e-07 2.64505922988546e-07 2.38444406096982e-07 3.47101823144428e-07 3.37625374999722e-07 3.20790426924069e-07 5.02178252920690e-08 1.73576015527609e-07 8.57402376593969e-07 1.80131811857122e-07 2.76964595681315e-07 2.14838038341036e-07 2.21053263051776e-07 1.59406260405821e-07 4.59614264881235e-08 3.78789455759776e-07 2.58966590318316e-07 7.75696011578299e-08 3.39990416320565e-07 3.24572509489827e-07 3.52020828992088e-08 6.49912862168267e-08 2.22828739301052e-07 2.13473046057573e-07 1.70720547021041e-07 2.19582224668132e-07 2.05914598785446e-07 1.14899310738254e-06 1.03415047080757e-07 1.89177690522258e-06 2.24175047702725e-07 3.76150153666139e-07 9.18124634120261e-08 2.27678254839140e-07 8.61346207114181e-08 3.38947999645138e-06 1.71880093129416e-07 2.22461873169689e-07 3.72427593494344e-08 6.76102058093114e-08 1.13163515787091e-06 7.04052219453715e-07 3.28310827940334e-07 2.12060821359437e-07 2.68576701610855e-07 2.04744061114503e-07 1.14622616867334e-07 4.35675529886048e-08 5.29665131717990e-08 3.50574437154752e-08 5.32920831968263e-08 1.04801149974382e-07 2.08316009852988e-07 2.77349913208742e-07 1.48756450473382e-07 3.78517042358300e-07 1.19222278136494e-07 4.57902170141890e-08 2.03249187200450e-07 9.32437812713631e-08 6.61503340988668e-07 1.01572927594225e-06 3.26294032932256e-07 2.26313604682662e-07 7.01012285236915e-08 7.61666326540900e-08 4.16954886967803e-08 4.41719683698357e-08 4.02549730011751e-08 4.41603434482274e-08 3.50371730851861e-08 3.00718061774876e-07 3.50372423542925e-08 5.32741630316562e-08 2.09046711312522e-07 3.75611845531339e-06 2.26535469768828e-07 4.62710159517236e-07 5.55357457448765e-07 4.16702305525217e-07 2.05922476618442e-07 2.06490274401431e-07 2.33754328058605e-07 1.66615319203810e-07 2.13390792614979e-07 2.54792444311713e-07 4.20241426628409e-07 6.95047952441784e-07 6.02254152247896e-07 1.56218004764843e-07 1.99836446669293e-07 1.62974708502310e-07 2.93420921132526e-07 1.67909832369442e-07 1.53692619622575e-07 8.89709805825161e-08 1.64148574413349e-07 1.82871518257336e-07 1.99566615308843e-07 1.59784291140960e-07 1.87893662090374e-07 2.77364481028229e-07 1.10443572547260e-07 2.18556580353372e-07 1.83932131011210e-07 7.94652011731045e-08 2.43919458395486e-07 1.59781205439559e-07 1.94642054497664e-07 1.29989372686070e-07 1.90910393259075e-07 2.84452061601644e-07 3.30006526167654e-07 1.93485493531741e-07 2.40209860863182e-07 4.15333943239071e-07 2.91343651778087e-07 2.58377576473351e-07 1.81274762632482e-07 1.88893039486970e-07 2.19428417763272e-07 2.20994023873646e-07 2.27950728874121e-07 1.64400439994395e-07 1.00341668297253e-07 1.67577483763212e-07 5.61980802260245e-08 3.04539633123467e-08 3.19018898206730e-08 3.89504322796163e-08 3.19941498021468e-07 5.41874921040340e-06 1.01776790218898e-06 1.29079721421378e-06 5.77887058141474e-07 2.79939362285509e-07 5.55989804582382e-08 2.11144624551603e-07 5.73140726411827e-08 5.35992572193921e-08 2.80066251579433e-07 1.76964657359828e-07 3.25199602895421e-07 2.18271466195228e-07 1.80628024038326e-07 4.69550563668357e-08 1.48055689005769e-07 1.82317859358405e-07 1.33063533148151e-07 2.62672490298873e-08 2.52416541944235e-08 2.08244390466210e-07 3.06261128674104e-07 2.18183988930487e-07 1.32114003617060e-07 3.13731744862144e-07 2.78980205382911e-07 2.42110700965470e-08 1.28818767334643e-07 3.48416502648141e-07 1.43250842379859e-07 2.58790299254369e-08 2.36803673262810e-08 2.54679999490770e-08 1.53423624973069e-07 2.11044574009824e-07 2.45219073821534e-08 5.40329423903049e-08 4.07828910547019e-08 2.86866659397290e-08 5.74108869690081e-08 3.17780519921456e-08 2.89072270765441e-07 6.46668413187508e-08 3.89801393203052e-07 1.62322978572959e-07 2.69026419637955e-07 4.76120100475985e-07 5.32185045407108e-07 1.57575408820348e-07 2.08858600548085e-07 1.87565977660685e-07 2.01108310997773e-07 3.95620143987532e-08 5.24866345380986e-08 8.64930520826212e-08 9.74072997804584e-07 2.54439638933078e-08 1.00154777975012e-07 9.42429455464106e-07 2.23088555779751e-07 2.02097796370716e-07 1.99163165408265e-07 9.26536634692885e-08 1.31298738607173e-07 1.97726692783641e-07 2.28150683478771e-07 2.17170907865184e-07 2.69677497220439e-08 1.54765400027711e-07 6.26255760215395e-08 1.46771827369792e-07 1.81515822529873e-07 1.72918459779846e-07 8.15990146285526e-08 9.85514009220808e-08 7.03396855430348e-07 5.93657045438661e-07 1.51834395684521e-07 9.76927764035926e-08 1.18527867299870e-07 2.71435324116586e-08 5.68571003566081e-08 1.65983256102705e-07 2.29129793972797e-07 5.88646431511064e-08 3.08684402204026e-05 2.38265317337181e-06 4.30752744717656e-07 1.04689461805175e-07 2.32270648752108e-07 6.07211466407868e-07 1.95341105985221e-08 7.38231690963101e-08 1.95129857199575e-07 4.01671898332107e-08 4.75072551754564e-08 2.49046064060719e-06 1.78142428447807e-07 2.60935684174315e-07 4.29594269700864e-08 1.14070714922750e-07 5.26390027271695e-08 6.74132420131039e-08 2.11045265009953e-07 7.27021148761358e-07 2.83886081059763e-07 2.76343292567963e-08 1.61294742863238e-07 1.83304573271511e-07 2.45251911632262e-07 9.18095053702886e-07 9.40457085677553e-07 2.90451584499496e-07 1.04003175628026e-07 1.08284695915254e-07 5.44402482199441e-08 2.02578013696944e-08 5.88615942025308e-08 1.04406254724335e-07 1.20598226687063e-07 5.71264670628078e-07 3.15144191075623e-07 2.23052176438872e-08 2.98936409995515e-08 2.92428609360162e-07 2.47505388371339e-07 2.72866577624107e-07 2.69881858030521e-07 1.85519336468060e-07 2.56402576998181e-07 8.88653855726949e-08 1.23281438816645e-07 3.74059740200056e-08 3.63466577344003e-08 1.20887062612203e-06 5.31728280982040e-07 2.22245937870703e-08 1.24471844746278e-07 5.11735373064063e-07 3.13008213548308e-07 5.70247343660301e-08 7.23194564373494e-07 1.79616235944090e-07 6.78737172874271e-08 1.87999018332358e-07 1.56051038058590e-07 2.31029093824182e-08 3.65957708093627e-08 5.13581582166058e-07 2.55008648105981e-08 1.44166238137747e-07 3.81609462756446e-07 2.16242665285891e-07 2.34087134829968e-07 2.55408939395098e-07 5.31844204547311e-08 1.37230800917903e-07 2.24923680386313e-07 7.91242025449375e-08 1.56574476334133e-07 1.34926252415438e-07 1.70013819330808e-08 1.48130847036606e-07 1.10651211565701e-07 1.58123074045499e-07 1.47865663105776e-07 1.14316450201195e-07 2.02955526741989e-08 1.49518466142608e-07 2.99469635848321e-08 4.06175629714119e-07 2.32871553385763e-07 1.70948094081342e-07 1.86984334344187e-07 1.54774299548728e-07 1.27005955203776e-07 7.29605614875902e-08 4.26639317987837e-08 5.91930531596668e-08 1.50666658228087e-08 4.86748534643297e-08 1.64538615062307e-08 1.32252962938291e-07 1.06729078335828e-07 1.39785078669013e-07 1.39779800669610e-07 9.26422941859900e-08 1.13233915195479e-07 8.32946711657419e-08 1.67451405167575e-07 3.65621117891888e-08 2.21661117907828e-07 3.65652178907218e-08 1.41441861581090e-06 3.30075312403152e-07 2.05346680636497e-08 2.16432978289422e-07 1.92694668921994e-07 1.99379501668891e-07 2.60904461669433e-07 2.16709099204294e-07 1.33136064843243e-07 1.52413473502972e-07 7.53889226907776e-07 3.22036453180506e-07 1.68931528429636e-07 1.04094510285934e-07 1.60098934336117e-07 1.02657996503878e-07 6.83661821001145e-08 1.61931255758191e-07 2.01320024686194e-07 1.07534006069169e-07 1.07910634894973e-07 9.46522813533042e-08 1.66743437525985e-07 1.78365196465516e-07 1.90349497426267e-07 1.99051143944893e-07 1.10969246755729e-07 1.11264782143939e-07 1.02006294022338e-07 1.24767050443006e-07 1.04932154146443e-07 1.03659587531759e-07 4.90478970104965e-08 9.01107885624077e-08 9.30802687007756e-08 2.06842405795697e-07 1.53448550376276e-07 9.79061221486547e-08 8.26140384317179e-08 1.50146254483116e-07 1.40136146748372e-07 1.56837338087257e-07 1.76198808159403e-07 1.99122966368083e-07 1.23858764266714e-07 1.06727895602262e-07 8.15204687804434e-08 1.88227798887152e-08 2.31668781894091e-08 7.67325491571661e-07 1.97158231154847e-07 1.04232262587474e-07 8.81089549804027e-09 1.09695696650620e-08 3.67828021042941e-07 2.42873900856430e-07 9.30400519863338e-08 1.22815336391232e-08 1.04498084973760e-07 4.13726864269242e-07 1.28584375991528e-08 1.20376581165868e-07 1.07046398186240e-07 5.96207309583810e-08 3.66763563633301e-08 1.21422552113772e-07 1.39822102904246e-07 1.58475758239753e-07 8.54716186106630e-08 9.47107273229749e-08 1.57282457487923e-07 2.22341833330773e-07 1.47297286955243e-07 2.19435143761748e-07 1.39688617089499e-07 7.24259126481027e-08 7.09641458863346e-08 1.19226547380480e-07 7.87372467318109e-08 9.72314598010880e-08 7.74647075656411e-09 9.47412998435404e-08 1.16751285273194e-07 1.13487779361823e-07 1.13827758524977e-07 2.72522446715463e-07 8.16170870703966e-08 8.72321297381038e-08 9.95784392252335e-08 2.65989252708394e-09 1.06630932742284e-07 9.36921419305549e-08 8.41656329617571e-08 1.30269792124746e-08 4.86904164038956e-06 1.01469686899418e-07 1.47172552045969e-07 1.11949067863535e-07 9.34802107168088e-08 6.41098286680338e-08 6.68095594366830e-09 4.65659962399765e-08 1.74321722504626e-07 1.53177157686198e-07 1.72679939394816e-07 9.26791009109865e-08 7.38280843033631e-09 1.21431764801520e-08 1.83474589517062e-08 5.49758746890643e-08 5.49686356365556e-08 5.41396143667257e-07 1.02078716839878e-08 1.46280082306786e-07 9.20039209747377e-08 1.07464173701763e-08 4.37249887631680e-08 1.20696543908951e-07 7.37023067237918e-08 1.54370995646110e-07 8.75880053587604e-08 1.38972473988507e-07 1.50011697718075e-07 1.13900910702895e-07 7.30960487245964e-08 1.06352204500379e-07 7.15892552073097e-09 1.26382007766409e-08 2.34492999966371e-07 9.25652500580458e-08 8.91104525001921e-08 1.04346566674604e-08 7.96833204055166e-08 3.41626685510968e-07 1.46859973263572e-07 6.99097620123092e-08 5.60565018753087e-08 9.18716519344181e-08 5.82078430390537e-09 8.51757309259611e-08 1.41028716092150e-07 7.10210717526897e-09 3.02205722277794e-08 2.76205242367368e-07 9.08403872147274e-08 8.55641175181640e-08 8.07674139440669e-08 5.64950026938399e-09 1.47871928050032e-07 1.37623718221666e-07 9.60980796219824e-08 9.05395061229061e-09 3.58713661087815e-07 3.78246981154481e-07 1.97627162656081e-08 4.78463482905684e-08 5.47976120635378e-07 5.98012738422856e-07 1.38288635243591e-07 3.97209746106909e-08 1.04405402152745e-07 1.64230983323839e-08 2.14721179480984e-08 4.85083210883807e-08 1.22646011220379e-06 8.39456826640735e-09 8.27662116573820e-08 3.58891263221149e-07 9.16048888640066e-08 1.21278839928491e-07 2.31054125718236e-07 1.00889365297461e-07 1.19358834432565e-07 2.43427211256917e-07 9.11020950715102e-08 1.38162844699562e-07 8.00915682468241e-08 4.98258405386454e-09 7.30080219716715e-08 1.52701681888474e-07 2.93328698184570e-07 1.35353313498113e-07 4.59682925254202e-08 9.08782411223864e-08 2.20927979357592e-08 9.05503229704100e-08 6.68343694641667e-08 7.33025736057753e-08 7.49958147508063e-08 6.22824091009223e-09 8.02682015058001e-06 3.67877032868707e-07 7.19496678750717e-08 3.17758490462365e-09 5.75563157661276e-09 3.24272951280416e-09 1.00381201383279e-07 1.88260239049035e-07 7.07194739983604e-08 4.68947848174950e-09 4.16252458503278e-09 7.94576959843098e-08 2.74009776209153e-07 1.42430916804990e-07 1.26235913248699e-07 1.39626029880374e-07 1.16782761195100e-07 1.00256563902946e-07 -2.95101260456139e-09 6.83432403678117e-08 1.27348806727558e-07 5.96766339731236e-08 1.03604721020808e-07 1.21085249476580e-07 6.80561072346092e-08 2.39948064835149e-09 1.00688731186191e-08 2.43035685127838e-08 4.13254891501583e-08 9.63544005596039e-09 2.53883818143423e-07 7.44890597640385e-07];
w0=0.002;
F=2*(pi^2)*(k^2).*z_diff.*Phi;
x0 = linspace(-0.02,0.02,Nx);y0=x0;[X0,Y0] = meshgrid(x0,y0);
Uin=exp(-(X0.^2+Y0.^2)/w0^2);
x = x + z_diff(1)*tan(beta);
screen1 = exp(1i*((Kx.*x) + (Ky.*y))).*delfx.*delfy.*sqrt(F(1)).*R ;
Uout = Uin.*exp(1i.*screen1);
c=[0.740664357812470 0.715162315217582 0.689780546528124 0.664556687838984 0.639501229779350 0.614618312979130 0.589909677254809 0.565375929219662 0.541017064806704 0.516832720551119 0.492822307973243 0.468985091286926 0.445320235117717 0.421826835235231 0.398503939126698 0.375350560217132 0.352365687964806 0.329548295192595 0.306897343515746 0.284411787427262 0.262090577416753 0.239932662380474 0.217936991503006 0.196102515739251 0.174428188990141 0.152912969040777 0.131555818312352 0.110355704466664 0.0893116008928944 0.0684224870996102 0.0476873490298864 0.0271051793136574 0.00667497746850089 0.0136042499421828 0.0337334891863653 0.0537137192700918 0.0735459118688980 0.0932310312800026 0.112770034392025 0.132163870669524 0.151413482150099 0.170519803452171 0.189483761791847 0.208306277007520 0.226988261591059 0.245530620724636 0.263934252322323 0.282200047075789 0.300328888503445 0.318321653002534 0.336179209903699 0.353902421527639 0.371492143243500 0.388949223528713 0.406274504030009 0.423468819625392 0.440532998486862 0.457467862143721 0.474274225546305 0.490952897130006 0.507504678879476 0.523930366392895 0.540230748946220 0.556406609557339 0.572458725050048 0.588387866117797 0.604194797387153 0.619880277480917 0.635445059080876 0.650889888990134 0.666215508194993 0.681422651926368 0.696512049720699 0.711484425480339 0.726340497533411 0.741080978693105 0.755706576316408 0.770217992362264 0.784615923449129 0.798901060911951 0.813074090858528 0.827135694225279 0.841086546832386 0.854927319438336 0.868658677793846 0.882281282695167 0.895795790036781 0.909202850863477 0.922503111421817 0.935697213210995 0.948785793033077 0.961769483042646 0.974648910795838 0.987424699298783 1.00009746705545 1.01266782811491 1.02513639211797 1.03750376434332 1.04977054575300 1.06193733303735 1.07400471865938 1.08597329089862 1.09784363389434 1.10961632768826 1.12129194826677 1.13287106760249 1.14435425369543 1.15574207061353 1.16703507853271 1.17823383377643 1.18933888885472 1.20035079250267 1.21127008971854 1.22209732180122 1.23283302638735 1.24347773748787 1.25403198552414 1.26449629736359 1.27487119635488 1.28515720236266 1.29535483180181 1.30546459767133 1.31548700958769 1.32542257381781 1.33527179331163 1.34503516773420 1.35471319349739 1.36430636379121 1.37381516861470 1.38324009480640 1.39258162607448 1.40184024302645 1.41101642319850 1.42011064108442 1.42912336816425 1.43805507293243 1.44690622092571 1.45567727475060 1.46436869411057 1.47298093583279 1.48151445389465 1.48996969944983 1.49834712085410 1.50664716369079 1.51487027079592 1.52301688228302 1.53108743556759 1.53908236539135 1.54700210384610 1.55484708039729 1.56261772190731 1.57031445265850 1.57793769437581 1.58548786624928 1.59296538495611 1.60037066468257 1.60770411714556 1.61496615161393 1.62215717492952 1.62927759152798 1.63632780345927 1.64330821040796 1.65021920971321 1.65706119638862 1.66383456314170 1.67053970039319 1.67717699629614 1.68374683675467 1.69024960544263 1.69668568382193 1.70305545116068 1.70935928455115 1.71559755892740 1.72177064708287 1.72787891968756 1.73392274530517 1.73990249040993 1.74581851940328 1.75167119463032 1.75746087639608 1.76318792298160 1.76885269065981 1.77445553371120 1.77999680443936 1.78547685318630 1.79089602834756 1.79625467638721 1.80155314185264 1.80679176738913 1.81197089375438 1.81709085983270 1.82215200264920 1.82715465738367 1.83209915738443 1.83698583418192 1.84181501750219 1.84658703528021 1.85130221367304 1.85596087707287 1.86056334811985 1.86510994771484 1.86960099503199 1.87403680753115 1.87841770097023 1.88274398941727 1.88701598526258 1.89123399923051 1.89539834039132 1.89950931617273 1.90356723237146 1.90757239316461 1.91152510112087 1.91542565721170 1.91927436082231 1.92307150976254 1.92681740027765 1.93051232705897 1.93415658325440 1.93775046047891 1.94129424882478 1.94478823687186 1.94823271169764 1.95162795888723 1.95497426254328 1.95827190529575 1.96152116831153 1.96472233130413 1.96787567254306 1.97098146886325 1.97403999567435 1.97705152696986 1.98001633533631 1.98293469196218 1.98580686664685 1.98863312780943 1.99141374249746 1.99414897639556 1.99683909383401 1.99948435779718 2.00208502993198 2.00464137055607 2.00715363866619 2.00962209194621 2.01204698677524 2.01442857823560 2.01676712012071 2.01906286494297 2.02131606394144 2.02352696708957 2.02569582310279 2.02782287944605 2.02990838234126 2.03195257677470 2.03395570650435 2.03591801406711 2.03783974078601 2.03972112677735 2.04156241095768 2.04336383105087 2.04512562359498 2.04684802394913 2.04853126630031 2.05017558367013 2.05178120792145 2.05334836976503 2.05487729876606 2.05636822335072 2.05782137081251 2.05923696731876 2.06061523791685 2.06195640654055 2.06326069601621 2.06452832806891 2.06575952332861 2.06695450133616 2.06811348054936 2.06923667834885 2.07032431104407 2.07137659387907 2.07239374103836 2.07337596565262 2.07432347980443 2.07523649453394 2.07611521984447 2.07695986470806 2.07777063707106 2.07854774385950 2.07929139098462 2.08000178334822 2.08067912484798 2.08132361838281 2.08193546585808 2.08251486819086 2.08306202531507 2.08357713618662 2.08406039878854 2.08451201013601 2.08493216628138 2.08532106231914 2.08567889239087 2.08600584969017 2.08630212646748 2.08656791403493 2.08680340277114 2.08700878212594 2.08718424062516 2.08732996587524 2.08744614456794 2.08753296248490 2.08759060450230 2.08761925459532 2.08761909584274 2.08759031043135 2.08753307966046 2.08744758394630 2.08733400282638 2.08719251496389 2.08702329815202 2.08682652931821 2.08660238452849 2.08635103899165 2.08607266706347 2.08576744225093 2.08543553721630 2.08507712378131 2.08469237293121 2.08428145481885 2.08384453876873 2.08338179328099 2.08289338603538 2.08237948389527 2.08184025291152 2.08127585832643 2.08068646457760 2.08007223530177 2.07943333333869 2.07876992073487 2.07808215874743 2.07737020784777 2.07663422772538 2.07587437729149 2.07509081468279 2.07428369726507 2.07345318163688 2.07259942363312 2.07172257832864 2.07082280004183 2.06990024233815 2.06895505803365 2.06798739919850 2.06699741716044 2.06598526250827 2.06495108509530 2.06389503404273 2.06281725774310 2.06171790386362 2.06059711934957 2.05945505042762 2.05829184260918 2.05710764069365 2.05590258877174 2.05467683022873 2.05343050774771 2.05216376331278 2.05087673821232 2.04956957304210 2.04824240770851 2.04689538143169 2.04552863274867 2.04414229951646 2.04273651891521 2.04131142745123 2.03986716096009 2.03840385460964 2.03692164290309 2.03542065968197 2.03390103812916 2.03236291077188 2.03080640948460 2.02923166549207 2.02763880937220 2.02602797105897 2.02439927984538 2.02275286438630 2.02108885270135 2.01940737217775 2.01770854957318 2.01599251101859 2.01425938202100 2.01250928746633 2.01074235162217 2.00895869814052 2.00715845006058 2.00534172981146 2.00350865921493 2.00165935948813 1.99979395124624 1.99791255450517 1.99601528868428 1.99410227260896 1.99217362451332 1.99022946204283 1.98826990225688 1.98629506163147 1.98430505606170 1.98230000086442 1.98028001078079 1.97824519997880 1.97619568205582 1.97413157004115 1.97205297639850 1.96996001302854 1.96785279127132 1.96573142190885 1.96359601516744 1.96144668072028 1.95928352768979 1.95710666465011 1.95491619962948 1.95271224011267 1.95049489304337 1.94826426482658 1.94602046133099 1.94376358789132 1.94149374931069 1.93921104986296 1.93691559329504 1.93460748282926 1.93228682116561 1.92995371048410 1.92760825244698 1.92525054820109 1.92288069838009 1.92049880310668 1.91810496199492 1.91569927415240 1.91328183818251 1.91085275218661 1.90841211376627 1.90596002002548 1.90349656757275 1.90102185252339 1.89853597050162 1.89603901664270 1.89353108559514 1.89101227152279 1.88848266810698 1.88594236854864 1.88339146557039 1.88083005141866 1.87825821786576 1.87567605621199 1.87308365728765 1.87048111145519 1.86786850861116 1.86524593818833 1.86261348915771 1.85997125003053 1.85731930886031 1.85465775324484 1.85198667032819 1.84930614680269 1.84661626891091 1.84391712244766 1.84120879276190 1.83849136475875 1.83576492290140 1.83302955121309 1.83028533327899 1.82753235224814 1.82477069083540 1.82200043132329 1.81922165556395 1.81643444498099 1.81363888057138 1.81083504290734 1.80802301213817 1.80520286799215 1.80237468977836 1.79953855638852 1.79669454629885 1.79384273757188 1.79098320785825 1.78811603439854 1.78524129402510 1.78235906316378 1.77946941783578 1.77657243365938 1.77366818585177 1.77075674923075 1.76783819821655 1.76491260683352 1.76198004871193 1.75904059708966 1.75609432481398 1.75314130434320 1.75018160774846 1.74721530671537 1.74424247254577 1.74126317615938 1.73827748809551 1.73528547851471 1.73228721720050 1.72928277356095 1.72627221663041 1.72325561507115 1.72023303717496 1.71720455086485 1.71417022369661 1.71113012286052 1.70808431518289 1.70503286712770 1.70197584479823 1.69891331393861 1.69584533993546 1.69277198781941 1.68969332226677 1.68660940760100 1.68352030779434 1.68042608646938 1.67732680690054 1.67422253201569 1.67111332439765 1.66799924628574 1.66488035957729 1.66175672582918 1.65862840625934 1.65549546174827 1.65235795284053 1.64921593974624 1.64606948234258 1.64291864017527 1.63976347246002 1.63660403808406 1.63344039560754 1.63027260326505 1.62710071896701 1.62392480030119 1.62074490453409 1.61756108861240 1.61437340916446 1.61118192250163 1.60798668461974 1.60478775120050 1.60158517761291 1.59837901891464 1.59516932985347 1.59195616486864 1.58873957809224 1.58551962335059 1.58229635416566 1.57906982375634 1.57584008503991 1.57260719063331 1.56937119285456 1.56613214372404 1.56289009496590 1.55964509800932 1.55639720398990 1.55314646375097 1.54989292784488 1.54663664653434 1.54337766979374 1.54011604731041 1.53685182848594 1.53358506243751 1.53031579799910 1.52704408372284 1.52376996788025 1.52049349846351 1.51721472318676 1.51393368948733 1.51065044452699 1.50736503519323 1.50407750810048 1.50078790959138 1.49749628573799 1.49420268234301 1.49090714494105 1.48760971879982 1.48431044892133 1.48100938004314 1.47770655663956 1.47440202292281 1.47109582284426 1.46778800009561 1.46447859811008 1.46116766006355 1.45785522887583 1.45454134721172 1.45122605748225 1.44790940184585 1.44459142220945 1.44127216022968 1.43795165731401 1.43462995462187 1.43130709306582 1.42798311331269 1.42465805578467 1.42133196066046 1.41800486787641 1.41467681712758 1.41134784786894 1.40801799931637 1.40468731044786 1.40135582000454 1.39802356649183 1.39469058818047 1.39135692310765 1.38802260907807 1.38468768366504 1.38135218421152 1.37801614783119 1.37467961140955 1.37134261160493 1.36800518484960 1.36466736735075 1.36132919509161 1.35799070383243 1.35465192911156 1.35131290624645 1.34797367033472 1.34463425625514 1.34129469866868 1.33795503201952 1.33461529053606 1.33127550823193 1.32793571890697 1.32459595614830 1.32125625333121 1.31791664362027 1.31457715997020 1.31123783512696 1.30789870162865 1.30455979180654 1.30122113778599 1.29788277148748 1.29454472462753 1.29120702871964 1.28786971507532 1.28453281480497 1.28119635881886 1.27786037782809 1.27452490234548 1.27118996268656 1.26785558897046 1.26452181112088 1.26118865886698 1.25785616174431 1.25452434909574 1.25119325007237 1.24786289363441 1.24453330855215 1.24120452340678 1.23787656659136 1.23454946631169 1.23122325058718 1.22789794725176 1.22457358395477 1.22125018816181 1.21792778715567 1.21460640803712 1.21128607772588 1.20796682296139 1.20464867030376 1.20133164613454 1.19801577665766 1.19470108790021 1.19138760571334 1.18807535577308 1.18476436358118 1.18145465446596 1.17814625358312 1.17483918591663 1.17153347627945 1.16822914931448 1.16492622949528 1.16162474112694 1.15832470834688 1.15502615512566 1.15172910526776 1.14843358241246 1.14513961003454 1.14184721144515 1.13855640979258 1.13526722806305 1.13197968908148 1.12869381551230 1.12540962986023 1.12212715447104 1.11884641153231 1.11556742307426 1.11229021097045 1.10901479693858 1.10574120254124 1.10246944918668 1.09919955812955 1.09593155047166 1.09266544716271 1.08940126900108 1.08613903663452 1.08287877056091 1.07962049112901 1.07636421853917 1.07310997284407 1.06985777394945 1.06660764161482 1.06335959545421 1.06011365493683 1.05686983938786 1.05362816798911 1.05038865977972 1.04715133365691 1.04391620837666 1.04068330255439 1.03745263466568 1.03422422304698 1.03099808589625 1.02777424127369 1.02455270710241 1.02133350116911 1.01811664112476 1.01490214448529 1.01169002863224 1.00848031081345 1.00527300814371 1.00206813760545 0.998865716049361 0.995665760195108 0.992468286631939 0.989273311819364 0.986080852087796 0.982890923639205 0.979703542547760 0.976518724760467 0.973336486097822 0.970156842254431 0.966979808799657 0.963805401178249 0.960633634710965 0.957464524595207 0.954298085905637 0.951134333594803 0.947973282493756 0.944814947312659 0.941659342641416 0.938506482950264 0.935356382590394 0.932209055794548 0.929064516677626 0.925922779237284 0.922783857354535 0.919647764794513 0.916514553007848 0.913626501586297 0.957181910437377 1.18507611517074];
Ri=z_diff./cos(beta);
screens = zeros(Nx,Nx,length(F)-1);
for i = 2:length(F)
x = x + z_diff(i)*tan(beta);
screens(:,:,i)= screens(:, :, i-1) + exp(1i*((Kx.*x)+(Ky.*y))).*delfx.*delfy.*sqrt(F(i)).*R;
Hi = exp(1i*Kz*Ri(i) – c(i).*Ri(i));
Ui = fftshift(fft2(Uout));
Ui = Hi.*Ui;
Ui = ifft2(ifftshift(Ui));
Uio = Ui.*exp(1i.*screens(:,:,i));
I = Uio.*conj(Uio);
Uout = Uio;
end
% to calculate SigmaI
A1=0;A2=0;
for i1=1:Nx
for i2=1:Nx
I1 = I(i1,i2)^2 ;
A1 = A1 + I1 ;
end
end
for j1=1:Nx
for j2=1:Nx
I2 = I(j1,j2) ;
A2 = A2 + I2;
end
end
SI = abs(((A1/Nx)/((A2/Nx)^2)) – 1);
%to calculate BER
syms u
PI = (1/(u*sqrt(2*pi*SI)))*exp(-((log(u) + SI )^2)/(2*SI)) ;
SNR0 = 1;
SNR = SNR0/sqrt(1+SI*SNR0) ;
fun = PI*erfc(real((SNR.*u)/(2*sqrt(2))));
ff = matlabFunction(fun,’Vars’,u);
BER = (0.5*integral(ff,0,Inf)) summation MATLAB Answers — New Questions