Category: Matlab
Category Archives: Matlab
After PCA, the reconstructed image is darker than the original.
original iris image
pca iris image
After PCA of the iris image, I reconstructed the image and it became dark. And when I analyzed the original image and PCA image with SSIM, the result was 0.09333. Other than that, I tried MSE and PSNR, and all the results showed low structural similarity between images. What part of the code should I modify to solve this problem?
clc; clear;
% Importing an iris image
i_image = ‘홍채 이미지 예시2.jpg’;
i = imread(i_image);
figure(1);
imshow(i);
title(‘Original Image’);
% Image RGB Channel Extraction
red = double(i(:, :, 1));
green = double(i(:, :, 2));
blue = double(i(:, :, 3));
% Specifying the number of principal components
num_components = 200;
% Red Channel PCA
[coeff_r, score_r, ~] = pca(red);
reduced_score_r = score_r(:, 1:num_components);
reconstructed_R = reduced_score_r * coeff_r(:, 1:num_components)’;
% Green Channel PCA
[coeff_g, score_g, ~] = pca(green);
reduced_score_g = score_g(:, 1:num_components);
reconstructed_G = reduced_score_g * coeff_g(:, 1:num_components)’;
% Blue Channel PCA
[coeff_b, score_b, ~] = pca(blue);
reduced_score_b = score_b(:, 1:num_components);
reconstructed_B = reduced_score_b * coeff_b(:, 1:num_components)’;
% Reconfiguring the image
reconstructed_red = reshape(reconstructed_R, size(red));
reconstructed_green = reshape(reconstructed_G, size(green));
reconstructed_blue = reshape(reconstructed_B, size(blue));
reconstructed_image = cat(3, uint8(reconstructed_red), uint8(reconstructed_green), uint8(reconstructed_blue));
% Show Reconfigured Images
figure(4);
imshow(uint8(reconstructed_image));
title(‘PCA Image’);
% SSIM
ssimval=ssim(i, reconstructed_image);
% MSE
err=immse(i, reconstructed_image);
% PSNR
peaksnr=psnr(i, reconstructed_image);original iris image
pca iris image
After PCA of the iris image, I reconstructed the image and it became dark. And when I analyzed the original image and PCA image with SSIM, the result was 0.09333. Other than that, I tried MSE and PSNR, and all the results showed low structural similarity between images. What part of the code should I modify to solve this problem?
clc; clear;
% Importing an iris image
i_image = ‘홍채 이미지 예시2.jpg’;
i = imread(i_image);
figure(1);
imshow(i);
title(‘Original Image’);
% Image RGB Channel Extraction
red = double(i(:, :, 1));
green = double(i(:, :, 2));
blue = double(i(:, :, 3));
% Specifying the number of principal components
num_components = 200;
% Red Channel PCA
[coeff_r, score_r, ~] = pca(red);
reduced_score_r = score_r(:, 1:num_components);
reconstructed_R = reduced_score_r * coeff_r(:, 1:num_components)’;
% Green Channel PCA
[coeff_g, score_g, ~] = pca(green);
reduced_score_g = score_g(:, 1:num_components);
reconstructed_G = reduced_score_g * coeff_g(:, 1:num_components)’;
% Blue Channel PCA
[coeff_b, score_b, ~] = pca(blue);
reduced_score_b = score_b(:, 1:num_components);
reconstructed_B = reduced_score_b * coeff_b(:, 1:num_components)’;
% Reconfiguring the image
reconstructed_red = reshape(reconstructed_R, size(red));
reconstructed_green = reshape(reconstructed_G, size(green));
reconstructed_blue = reshape(reconstructed_B, size(blue));
reconstructed_image = cat(3, uint8(reconstructed_red), uint8(reconstructed_green), uint8(reconstructed_blue));
% Show Reconfigured Images
figure(4);
imshow(uint8(reconstructed_image));
title(‘PCA Image’);
% SSIM
ssimval=ssim(i, reconstructed_image);
% MSE
err=immse(i, reconstructed_image);
% PSNR
peaksnr=psnr(i, reconstructed_image); original iris image
pca iris image
After PCA of the iris image, I reconstructed the image and it became dark. And when I analyzed the original image and PCA image with SSIM, the result was 0.09333. Other than that, I tried MSE and PSNR, and all the results showed low structural similarity between images. What part of the code should I modify to solve this problem?
clc; clear;
% Importing an iris image
i_image = ‘홍채 이미지 예시2.jpg’;
i = imread(i_image);
figure(1);
imshow(i);
title(‘Original Image’);
% Image RGB Channel Extraction
red = double(i(:, :, 1));
green = double(i(:, :, 2));
blue = double(i(:, :, 3));
% Specifying the number of principal components
num_components = 200;
% Red Channel PCA
[coeff_r, score_r, ~] = pca(red);
reduced_score_r = score_r(:, 1:num_components);
reconstructed_R = reduced_score_r * coeff_r(:, 1:num_components)’;
% Green Channel PCA
[coeff_g, score_g, ~] = pca(green);
reduced_score_g = score_g(:, 1:num_components);
reconstructed_G = reduced_score_g * coeff_g(:, 1:num_components)’;
% Blue Channel PCA
[coeff_b, score_b, ~] = pca(blue);
reduced_score_b = score_b(:, 1:num_components);
reconstructed_B = reduced_score_b * coeff_b(:, 1:num_components)’;
% Reconfiguring the image
reconstructed_red = reshape(reconstructed_R, size(red));
reconstructed_green = reshape(reconstructed_G, size(green));
reconstructed_blue = reshape(reconstructed_B, size(blue));
reconstructed_image = cat(3, uint8(reconstructed_red), uint8(reconstructed_green), uint8(reconstructed_blue));
% Show Reconfigured Images
figure(4);
imshow(uint8(reconstructed_image));
title(‘PCA Image’);
% SSIM
ssimval=ssim(i, reconstructed_image);
% MSE
err=immse(i, reconstructed_image);
% PSNR
peaksnr=psnr(i, reconstructed_image); pca, matlab, image MATLAB Answers — New Questions
Simulink Electric generator with pulley.
I’m new to simulink and I have no idea how to make a model of the electric generator that I made, I need help please.I’m new to simulink and I have no idea how to make a model of the electric generator that I made, I need help please. I’m new to simulink and I have no idea how to make a model of the electric generator that I made, I need help please. simulink, matlab MATLAB Answers — New Questions
Can anyone explain how to create (short-circuit) overcurrent in Matlab simulink?
Hello.
I am a student, trying to make the overcurrent analysis in PV integrated LLC resonant DC/DC converter and trying to design the fault-tolerant one for my graduation thesis paper. But the problem that I am facing with is that I don’t know how to create overcurrent in it. Can anyone please teach me which block in Matlab can I use to create overcurrent or fault in LLC resonant converter?Hello.
I am a student, trying to make the overcurrent analysis in PV integrated LLC resonant DC/DC converter and trying to design the fault-tolerant one for my graduation thesis paper. But the problem that I am facing with is that I don’t know how to create overcurrent in it. Can anyone please teach me which block in Matlab can I use to create overcurrent or fault in LLC resonant converter? Hello.
I am a student, trying to make the overcurrent analysis in PV integrated LLC resonant DC/DC converter and trying to design the fault-tolerant one for my graduation thesis paper. But the problem that I am facing with is that I don’t know how to create overcurrent in it. Can anyone please teach me which block in Matlab can I use to create overcurrent or fault in LLC resonant converter? llc resonant converter, overcurrent, fault analysis MATLAB Answers — New Questions
Find the coordinates of the nodes of an matrix inside another matrix
I would like to find the coordinates of the nodes of an matrix ‘nodes_portion’ inside a larger matrix ‘nodes_e’. (In this case all ‘nodes_portion’ is contained in ‘nodes_e’).
What I want to get are the rows where the nodes of ‘nodes_portion’ are inside ‘nodes_e’.
I am using a for loop however it takes much longer than expected. Any way to optimize the search?
nodes_file = importdata("nodes.mat");
nodes_e = nodes_file.nodes_e;
nodes_portion = nodes_file.nodes_portion;
row_t = {};
for j = 1:5 %:height(nodes_portion)
row = {};
for k = 1:height(nodes_e)
[r,~] = find(nodes_e(k,1) == nodes_portion(j,1) & nodes_e(k,2) == nodes_portion(j,2) & nodes_e(k,3) == nodes_portion(j,3));
row = [row;{r}];
end
row_t = [row_t;{row}];
end
% ==========
rr = {};
for s = 1:height(row_t)
[r,c] = find(cellfun(@(x) isequal(x,1), row_t{s,1}(:,1)));
rr = [rr;{r}];
endI would like to find the coordinates of the nodes of an matrix ‘nodes_portion’ inside a larger matrix ‘nodes_e’. (In this case all ‘nodes_portion’ is contained in ‘nodes_e’).
What I want to get are the rows where the nodes of ‘nodes_portion’ are inside ‘nodes_e’.
I am using a for loop however it takes much longer than expected. Any way to optimize the search?
nodes_file = importdata("nodes.mat");
nodes_e = nodes_file.nodes_e;
nodes_portion = nodes_file.nodes_portion;
row_t = {};
for j = 1:5 %:height(nodes_portion)
row = {};
for k = 1:height(nodes_e)
[r,~] = find(nodes_e(k,1) == nodes_portion(j,1) & nodes_e(k,2) == nodes_portion(j,2) & nodes_e(k,3) == nodes_portion(j,3));
row = [row;{r}];
end
row_t = [row_t;{row}];
end
% ==========
rr = {};
for s = 1:height(row_t)
[r,c] = find(cellfun(@(x) isequal(x,1), row_t{s,1}(:,1)));
rr = [rr;{r}];
end I would like to find the coordinates of the nodes of an matrix ‘nodes_portion’ inside a larger matrix ‘nodes_e’. (In this case all ‘nodes_portion’ is contained in ‘nodes_e’).
What I want to get are the rows where the nodes of ‘nodes_portion’ are inside ‘nodes_e’.
I am using a for loop however it takes much longer than expected. Any way to optimize the search?
nodes_file = importdata("nodes.mat");
nodes_e = nodes_file.nodes_e;
nodes_portion = nodes_file.nodes_portion;
row_t = {};
for j = 1:5 %:height(nodes_portion)
row = {};
for k = 1:height(nodes_e)
[r,~] = find(nodes_e(k,1) == nodes_portion(j,1) & nodes_e(k,2) == nodes_portion(j,2) & nodes_e(k,3) == nodes_portion(j,3));
row = [row;{r}];
end
row_t = [row_t;{row}];
end
% ==========
rr = {};
for s = 1:height(row_t)
[r,c] = find(cellfun(@(x) isequal(x,1), row_t{s,1}(:,1)));
rr = [rr;{r}];
end find, coordinates, nodes, cellfun MATLAB Answers — New Questions
search interval in datetime
hi, I have a datetime array of several many days. I need to serch interval
example:
TimeA=22:00
TimeB=03:00
search datetime>=timeA and datetime<=timeB (22:00 ..22:01..22:02. etc……23:59 ..00:00…00:01.etc… 2:58..2:59 3:00)
So I want without checking the day to have the indices of that range in the whole array
(the times in datetime are already ordered in a correct chronological way so the next time is always after the previous one)hi, I have a datetime array of several many days. I need to serch interval
example:
TimeA=22:00
TimeB=03:00
search datetime>=timeA and datetime<=timeB (22:00 ..22:01..22:02. etc……23:59 ..00:00…00:01.etc… 2:58..2:59 3:00)
So I want without checking the day to have the indices of that range in the whole array
(the times in datetime are already ordered in a correct chronological way so the next time is always after the previous one) hi, I have a datetime array of several many days. I need to serch interval
example:
TimeA=22:00
TimeB=03:00
search datetime>=timeA and datetime<=timeB (22:00 ..22:01..22:02. etc……23:59 ..00:00…00:01.etc… 2:58..2:59 3:00)
So I want without checking the day to have the indices of that range in the whole array
(the times in datetime are already ordered in a correct chronological way so the next time is always after the previous one) search interval in datetime MATLAB Answers — New Questions
Converting a cell array to can message timetable
I am trying to convert a cell array into can message timetable format ,
% Given cell array
canMessageCell = {‘Timestamp 1546909042’, ‘Interface ”can0”’, ‘ID ”0B9”’, ‘Data [0,4,0,0,0,0,0,0]’};
% Extract the information from the cell array
timestampStr = canMessageCell{1};
idStr = canMessageCell{3};
dataStr = canMessageCell{4};
% Convert extracted strings to proper data types
timestamp = datetime(str2double(extractAfter(timestampStr, ‘Timestamp ‘)), ‘ConvertFrom’, ‘posixtime’);
id = hex2dec(extractBetween(idStr, ‘ID ”’, ””));
% Extract the data portion and convert it to a numeric array
dataChar = extractBetween(dataStr, ‘Data [‘, ‘]’);
data = str2num(dataChar{1}); % Convert cell array to character vector before using str2num
% Assume the CAN message is not an extended frame, not a remote frame, and has no error
isExtended = false;
isRemote = false;
hasError = false;
% Create a structure array with the expected field names
canMessageStruct = struct(‘TimeStamp’, timestamp, ‘ID’, id, ‘Data’, {data}, ‘Extended’, isExtended, ‘Remote’, isRemote, ‘Error’, hasError);
% Convert the structure array to a cell array
canMessageCell = {canMessageStruct};
% Load the DBC file (replace with the actual path to your DBC file)
dbcFile = ‘drivekit_kia_soul_ev.dbc’;
db = canDatabase(dbcFile);
% Convert the cell array to a canMessageTimetable
msgTimetable = canMessageTimetable(canMessageCell, db);
% Display the result
disp(msgTimetable);
I am following this syntax for converting my cell array into CAN message timetable db = canDatabase(‘myDatabase.dbc’)
msgTimetable = canMessageTimetable(canMsgs,db) but I am getting this error, Error using ()
Timetable row subscript must be a numeric, logical, or datetime array, or a timerange subscripter.
Error in canmessagetimetableconversion (line 33)
msgTimetable = canMessageTimetable(canMessageCell, db);
I dont know why because my timestamp is in datetime format as i converted it from posix format, my data is in uint8 format and I have created a struct for my timestamp, ID , Data , I have assumed Extended, Remote, Error to be false , if anyone can please help me in debugging this issue as i have been stuck on this , it would be greatly appreciated.I am trying to convert a cell array into can message timetable format ,
% Given cell array
canMessageCell = {‘Timestamp 1546909042’, ‘Interface ”can0”’, ‘ID ”0B9”’, ‘Data [0,4,0,0,0,0,0,0]’};
% Extract the information from the cell array
timestampStr = canMessageCell{1};
idStr = canMessageCell{3};
dataStr = canMessageCell{4};
% Convert extracted strings to proper data types
timestamp = datetime(str2double(extractAfter(timestampStr, ‘Timestamp ‘)), ‘ConvertFrom’, ‘posixtime’);
id = hex2dec(extractBetween(idStr, ‘ID ”’, ””));
% Extract the data portion and convert it to a numeric array
dataChar = extractBetween(dataStr, ‘Data [‘, ‘]’);
data = str2num(dataChar{1}); % Convert cell array to character vector before using str2num
% Assume the CAN message is not an extended frame, not a remote frame, and has no error
isExtended = false;
isRemote = false;
hasError = false;
% Create a structure array with the expected field names
canMessageStruct = struct(‘TimeStamp’, timestamp, ‘ID’, id, ‘Data’, {data}, ‘Extended’, isExtended, ‘Remote’, isRemote, ‘Error’, hasError);
% Convert the structure array to a cell array
canMessageCell = {canMessageStruct};
% Load the DBC file (replace with the actual path to your DBC file)
dbcFile = ‘drivekit_kia_soul_ev.dbc’;
db = canDatabase(dbcFile);
% Convert the cell array to a canMessageTimetable
msgTimetable = canMessageTimetable(canMessageCell, db);
% Display the result
disp(msgTimetable);
I am following this syntax for converting my cell array into CAN message timetable db = canDatabase(‘myDatabase.dbc’)
msgTimetable = canMessageTimetable(canMsgs,db) but I am getting this error, Error using ()
Timetable row subscript must be a numeric, logical, or datetime array, or a timerange subscripter.
Error in canmessagetimetableconversion (line 33)
msgTimetable = canMessageTimetable(canMessageCell, db);
I dont know why because my timestamp is in datetime format as i converted it from posix format, my data is in uint8 format and I have created a struct for my timestamp, ID , Data , I have assumed Extended, Remote, Error to be false , if anyone can please help me in debugging this issue as i have been stuck on this , it would be greatly appreciated. I am trying to convert a cell array into can message timetable format ,
% Given cell array
canMessageCell = {‘Timestamp 1546909042’, ‘Interface ”can0”’, ‘ID ”0B9”’, ‘Data [0,4,0,0,0,0,0,0]’};
% Extract the information from the cell array
timestampStr = canMessageCell{1};
idStr = canMessageCell{3};
dataStr = canMessageCell{4};
% Convert extracted strings to proper data types
timestamp = datetime(str2double(extractAfter(timestampStr, ‘Timestamp ‘)), ‘ConvertFrom’, ‘posixtime’);
id = hex2dec(extractBetween(idStr, ‘ID ”’, ””));
% Extract the data portion and convert it to a numeric array
dataChar = extractBetween(dataStr, ‘Data [‘, ‘]’);
data = str2num(dataChar{1}); % Convert cell array to character vector before using str2num
% Assume the CAN message is not an extended frame, not a remote frame, and has no error
isExtended = false;
isRemote = false;
hasError = false;
% Create a structure array with the expected field names
canMessageStruct = struct(‘TimeStamp’, timestamp, ‘ID’, id, ‘Data’, {data}, ‘Extended’, isExtended, ‘Remote’, isRemote, ‘Error’, hasError);
% Convert the structure array to a cell array
canMessageCell = {canMessageStruct};
% Load the DBC file (replace with the actual path to your DBC file)
dbcFile = ‘drivekit_kia_soul_ev.dbc’;
db = canDatabase(dbcFile);
% Convert the cell array to a canMessageTimetable
msgTimetable = canMessageTimetable(canMessageCell, db);
% Display the result
disp(msgTimetable);
I am following this syntax for converting my cell array into CAN message timetable db = canDatabase(‘myDatabase.dbc’)
msgTimetable = canMessageTimetable(canMsgs,db) but I am getting this error, Error using ()
Timetable row subscript must be a numeric, logical, or datetime array, or a timerange subscripter.
Error in canmessagetimetableconversion (line 33)
msgTimetable = canMessageTimetable(canMessageCell, db);
I dont know why because my timestamp is in datetime format as i converted it from posix format, my data is in uint8 format and I have created a struct for my timestamp, ID , Data , I have assumed Extended, Remote, Error to be false , if anyone can please help me in debugging this issue as i have been stuck on this , it would be greatly appreciated. cell array, can message timetable conversion MATLAB Answers — New Questions
Use of tensorprod function to compute multilinear forms
Hi everyone,
I have to compute the multilinear form of a tensor and a vector. Suppose for example we have a 4-dimensional tensor A and a vector v. The 4-linear form is the multiplication of A by v 4 times. The only way that I found to do this is to use "for" loops. I think there must be a way to use the "tensorprod" function to perform the operation more efficiently but I can’t find it. Thank you in advance to anyone who can help.
Cheers
n = 3;
A = rand(n,n,n,n);
v = rand(n,1);
for j = 1:n
for k = 1:n
G(:,k,j) = squeeze(v’*A(:,:,k,j));
end
end
for j = 1:n
J(:,j) = squeeze(v’*G(:,:,j));
end
res = v’*J*v;Hi everyone,
I have to compute the multilinear form of a tensor and a vector. Suppose for example we have a 4-dimensional tensor A and a vector v. The 4-linear form is the multiplication of A by v 4 times. The only way that I found to do this is to use "for" loops. I think there must be a way to use the "tensorprod" function to perform the operation more efficiently but I can’t find it. Thank you in advance to anyone who can help.
Cheers
n = 3;
A = rand(n,n,n,n);
v = rand(n,1);
for j = 1:n
for k = 1:n
G(:,k,j) = squeeze(v’*A(:,:,k,j));
end
end
for j = 1:n
J(:,j) = squeeze(v’*G(:,:,j));
end
res = v’*J*v; Hi everyone,
I have to compute the multilinear form of a tensor and a vector. Suppose for example we have a 4-dimensional tensor A and a vector v. The 4-linear form is the multiplication of A by v 4 times. The only way that I found to do this is to use "for" loops. I think there must be a way to use the "tensorprod" function to perform the operation more efficiently but I can’t find it. Thank you in advance to anyone who can help.
Cheers
n = 3;
A = rand(n,n,n,n);
v = rand(n,1);
for j = 1:n
for k = 1:n
G(:,k,j) = squeeze(v’*A(:,:,k,j));
end
end
for j = 1:n
J(:,j) = squeeze(v’*G(:,:,j));
end
res = v’*J*v; tensors, multilinear forms MATLAB Answers — New Questions
New Script keeps opening in new window instead of a tab
So, stupid question. I accidentally did something on my script file and now when I hit new script, it opens a new script in a new window instead of a new tab. Can someone tell me what I did and how to reverse it.
ThanksSo, stupid question. I accidentally did something on my script file and now when I hit new script, it opens a new script in a new window instead of a new tab. Can someone tell me what I did and how to reverse it.
Thanks So, stupid question. I accidentally did something on my script file and now when I hit new script, it opens a new script in a new window instead of a new tab. Can someone tell me what I did and how to reverse it.
Thanks script, live script MATLAB Answers — New Questions
MATLAB code for ILEACH protocol in WSN reqired
I am working on WSN routing protocols simulation. I need matlab code for ILEACH protocol asap. If anyone has please do reply soon.I am working on WSN routing protocols simulation. I need matlab code for ILEACH protocol asap. If anyone has please do reply soon. I am working on WSN routing protocols simulation. I need matlab code for ILEACH protocol asap. If anyone has please do reply soon. for loop MATLAB Answers — New Questions
How do I plot a symbolic equation that I have created?
Hello everyone. I am about a month into a uni project and I am stuck on something that I cannot figure out, despite weeks of little bits of test code and Googling. I won’t share the whole thing, as it’s a project and currently about 350 lines. In general though, I have built something that solves the differential equations for an RLC circuit, showing all the working using symbolic maths.
So I get it down to the point where I have my symbol (Yt) which is equal to: val=1.0 – 0.2*exp(-1.0*t)*sin(5.0*t) – 1.0*exp(-1.0*t)*cos(5.0*t)
I have then successfully used fplot to draw this equation. However, I am now trying to demonstrate time invariance. The only way that I can find to do this is by creating a time vector, and then plotting the equation against time+1, similar to the test code below.
InputStartTime = 1
t=0:.005:5;
hold on;
test3 = -1.0*exp(-1.0*t).*cos(5.0*t)- 0.2*exp(-1.0*t).*sin(5.0*t) + 1
firstPoint = test3(1) % start point of function
plot(t+InputStartTime,test3)
plot([0 (t(1)+InputStartTime)], [0 firstPoint]) % Plot line from origin to start point of delayed function
However, and this is the key, test3 above is hardcoded. I cannot find a way of getting the sym into a format that I can use. If I try something like string, MATLAB then complains that the matrices are the "Incorrect dimensions for matrix multiplication". I then had to change the ‘*’ to ‘.*’ in the above equation. I have no idea how to take my solved equation from Symbolic maths and use it like this. Can anyone help please? This is how the formula looks once I have solved it, with yt being a "1×1 sym".
performing a string() of this gives: "1.0 – 0.2*exp(-1.0*t)*sin(5.0*t) – 1.0*exp(-1.0*t)*cos(5.0*t)" which shows that there is a * between exp() and sin/cos.Hello everyone. I am about a month into a uni project and I am stuck on something that I cannot figure out, despite weeks of little bits of test code and Googling. I won’t share the whole thing, as it’s a project and currently about 350 lines. In general though, I have built something that solves the differential equations for an RLC circuit, showing all the working using symbolic maths.
So I get it down to the point where I have my symbol (Yt) which is equal to: val=1.0 – 0.2*exp(-1.0*t)*sin(5.0*t) – 1.0*exp(-1.0*t)*cos(5.0*t)
I have then successfully used fplot to draw this equation. However, I am now trying to demonstrate time invariance. The only way that I can find to do this is by creating a time vector, and then plotting the equation against time+1, similar to the test code below.
InputStartTime = 1
t=0:.005:5;
hold on;
test3 = -1.0*exp(-1.0*t).*cos(5.0*t)- 0.2*exp(-1.0*t).*sin(5.0*t) + 1
firstPoint = test3(1) % start point of function
plot(t+InputStartTime,test3)
plot([0 (t(1)+InputStartTime)], [0 firstPoint]) % Plot line from origin to start point of delayed function
However, and this is the key, test3 above is hardcoded. I cannot find a way of getting the sym into a format that I can use. If I try something like string, MATLAB then complains that the matrices are the "Incorrect dimensions for matrix multiplication". I then had to change the ‘*’ to ‘.*’ in the above equation. I have no idea how to take my solved equation from Symbolic maths and use it like this. Can anyone help please? This is how the formula looks once I have solved it, with yt being a "1×1 sym".
performing a string() of this gives: "1.0 – 0.2*exp(-1.0*t)*sin(5.0*t) – 1.0*exp(-1.0*t)*cos(5.0*t)" which shows that there is a * between exp() and sin/cos. Hello everyone. I am about a month into a uni project and I am stuck on something that I cannot figure out, despite weeks of little bits of test code and Googling. I won’t share the whole thing, as it’s a project and currently about 350 lines. In general though, I have built something that solves the differential equations for an RLC circuit, showing all the working using symbolic maths.
So I get it down to the point where I have my symbol (Yt) which is equal to: val=1.0 – 0.2*exp(-1.0*t)*sin(5.0*t) – 1.0*exp(-1.0*t)*cos(5.0*t)
I have then successfully used fplot to draw this equation. However, I am now trying to demonstrate time invariance. The only way that I can find to do this is by creating a time vector, and then plotting the equation against time+1, similar to the test code below.
InputStartTime = 1
t=0:.005:5;
hold on;
test3 = -1.0*exp(-1.0*t).*cos(5.0*t)- 0.2*exp(-1.0*t).*sin(5.0*t) + 1
firstPoint = test3(1) % start point of function
plot(t+InputStartTime,test3)
plot([0 (t(1)+InputStartTime)], [0 firstPoint]) % Plot line from origin to start point of delayed function
However, and this is the key, test3 above is hardcoded. I cannot find a way of getting the sym into a format that I can use. If I try something like string, MATLAB then complains that the matrices are the "Incorrect dimensions for matrix multiplication". I then had to change the ‘*’ to ‘.*’ in the above equation. I have no idea how to take my solved equation from Symbolic maths and use it like this. Can anyone help please? This is how the formula looks once I have solved it, with yt being a "1×1 sym".
performing a string() of this gives: "1.0 – 0.2*exp(-1.0*t)*sin(5.0*t) – 1.0*exp(-1.0*t)*cos(5.0*t)" which shows that there is a * between exp() and sin/cos. symbolic, plot MATLAB Answers — New Questions
Unable to open the requested feature. Check your internet connection and proxy settings in MATLAB Web preferences and then try starting the feature again. Detailed information
out = parsim(simInput,’ShowSimulationManager’,’on’);
To check the parallel operation process of the simulation link file in real time with the above code, the following error window and error message occur.
I should be very grateful to you if you might help me.out = parsim(simInput,’ShowSimulationManager’,’on’);
To check the parallel operation process of the simulation link file in real time with the above code, the following error window and error message occur.
I should be very grateful to you if you might help me. out = parsim(simInput,’ShowSimulationManager’,’on’);
To check the parallel operation process of the simulation link file in real time with the above code, the following error window and error message occur.
I should be very grateful to you if you might help me. parallel computing toolbox, show simulation manager MATLAB Answers — New Questions
Drawing backward and forward points using intrinsic low dimensional manifold (ILDM)
I am trying to draw the backward and forward points of the slow invariant manifold (SIM) from the equilibrium point using the following code of Intrinsic low dimensional manifold (ILDM), but didn’t get all backward points. could anyone identify the mistake.
by using below code i am getting following graph which is not plotting the backward points
i am trying to get following result, but unfortunately there is a mistake in my code.
code:
% A + Z <=====> AZ
% AZ + B <=====> AB + Z
% Let A=c1, B=c2, Z=c3, AZ=c4 and AB=c5
% c1 + c3 <=====> c4 % c4 + c2 <=====> c5 + c3
clc;
clear
syms c1 c2 c3 c4 c5 x1 x2
syms k1p k2p k1n k2n %positive and negative k’s
%Stoichiometric Vectors
r1 = [-1; 0; -1; 1; 0];
r2 = [0; -1; 1; -1; 1];
%Parameters
k1p=1; k2p=0.5; k3p=1 ;
EP=[.5 .1 .1 .4 .1]; %Equilibrium Point
C1=EP(1); C2=EP(2); C3=EP(3); C4=EP(4); C5=EP(5);
%Finding k1n, k2n (((((((((((((((((((((((((((((((( %Reaction Rates
w1 = k1p*C1*C3 – k1n*C4;
w2 = k2p*C4*C2 – k2n*C5*C3;
%solving for k1n and k2n
k1n=solve(w1==0, k1n);
k2n=solve(w2==0, k2n);
%)))))))))))))))))))))))))))))))))))))))))))))))))
%Molecular Matrix[1 0 0 1 1; 0 1 0 0 1; 0 0 1 1 0]
bA = C1+C3+C4; %for A
bB = C2+C5; %for B
bZ = C3+C4; %for Z
% Reducing the system for species c1=A, c4=AZ;
c3 = bZ – c4;
c5 = bA – c1 – c4;
c2 = bB – c5;
%Reaction Rates
w1 = k1p*c1*c3 – k1n*c4;
w2 = k2p*c4*c2 – k2n*c5*c3;
%Using Law of Conservation of Mass
G = r1*w1 + r2*w2;
%Reduced System
F = [G(1); G(4)];
F = subs(F,[c1,c4],[x1,x2]);
EP = [C1; C4];
m=20; n=17; %no of points forward and backward to the equilibrium point
h=0.03; %constant increment
%Finding points above EP
P=EP; r=P;
for forward = 1:m
J = ILDM1D_jacobian(F,r);
b = ILDM1D_slowest(J);
r = P + h*b;
Q = ILDM1D_projection(J);
P = ILDM1D_manifold(Q,F,r);
allForward(forward,:) = P; % all Forward matrix stores all forward points
end
%Finding points below EP
P=EP; r=P;
for backward =1:n
J= ILDM1D_jacobian (F,r);
b = ILDM1D_slowest (J);
r = P + h*b;
Q= ILDM1D_projection (J);
ILDM1D_manifold (Q,F,r);
allBackward(backward,:) = P;
%allBackward matrix stores all backward points
end
%Plotting
plot (EP (1),EP (2), ‘ks’);hold on;
plot (allForward(:,1),allForward(:,2),’+k-‘);
plot (allBackward(:,2),allBackward(:,2),’*k-‘);
grid on;
axis ([0 1 0 .7]);
xlabel (‘A’); ylabel (‘AZ’);
legend(‘Eguilibrium point’, ‘Forward direction’, ‘Backword direction’)I am trying to draw the backward and forward points of the slow invariant manifold (SIM) from the equilibrium point using the following code of Intrinsic low dimensional manifold (ILDM), but didn’t get all backward points. could anyone identify the mistake.
by using below code i am getting following graph which is not plotting the backward points
i am trying to get following result, but unfortunately there is a mistake in my code.
code:
% A + Z <=====> AZ
% AZ + B <=====> AB + Z
% Let A=c1, B=c2, Z=c3, AZ=c4 and AB=c5
% c1 + c3 <=====> c4 % c4 + c2 <=====> c5 + c3
clc;
clear
syms c1 c2 c3 c4 c5 x1 x2
syms k1p k2p k1n k2n %positive and negative k’s
%Stoichiometric Vectors
r1 = [-1; 0; -1; 1; 0];
r2 = [0; -1; 1; -1; 1];
%Parameters
k1p=1; k2p=0.5; k3p=1 ;
EP=[.5 .1 .1 .4 .1]; %Equilibrium Point
C1=EP(1); C2=EP(2); C3=EP(3); C4=EP(4); C5=EP(5);
%Finding k1n, k2n (((((((((((((((((((((((((((((((( %Reaction Rates
w1 = k1p*C1*C3 – k1n*C4;
w2 = k2p*C4*C2 – k2n*C5*C3;
%solving for k1n and k2n
k1n=solve(w1==0, k1n);
k2n=solve(w2==0, k2n);
%)))))))))))))))))))))))))))))))))))))))))))))))))
%Molecular Matrix[1 0 0 1 1; 0 1 0 0 1; 0 0 1 1 0]
bA = C1+C3+C4; %for A
bB = C2+C5; %for B
bZ = C3+C4; %for Z
% Reducing the system for species c1=A, c4=AZ;
c3 = bZ – c4;
c5 = bA – c1 – c4;
c2 = bB – c5;
%Reaction Rates
w1 = k1p*c1*c3 – k1n*c4;
w2 = k2p*c4*c2 – k2n*c5*c3;
%Using Law of Conservation of Mass
G = r1*w1 + r2*w2;
%Reduced System
F = [G(1); G(4)];
F = subs(F,[c1,c4],[x1,x2]);
EP = [C1; C4];
m=20; n=17; %no of points forward and backward to the equilibrium point
h=0.03; %constant increment
%Finding points above EP
P=EP; r=P;
for forward = 1:m
J = ILDM1D_jacobian(F,r);
b = ILDM1D_slowest(J);
r = P + h*b;
Q = ILDM1D_projection(J);
P = ILDM1D_manifold(Q,F,r);
allForward(forward,:) = P; % all Forward matrix stores all forward points
end
%Finding points below EP
P=EP; r=P;
for backward =1:n
J= ILDM1D_jacobian (F,r);
b = ILDM1D_slowest (J);
r = P + h*b;
Q= ILDM1D_projection (J);
ILDM1D_manifold (Q,F,r);
allBackward(backward,:) = P;
%allBackward matrix stores all backward points
end
%Plotting
plot (EP (1),EP (2), ‘ks’);hold on;
plot (allForward(:,1),allForward(:,2),’+k-‘);
plot (allBackward(:,2),allBackward(:,2),’*k-‘);
grid on;
axis ([0 1 0 .7]);
xlabel (‘A’); ylabel (‘AZ’);
legend(‘Eguilibrium point’, ‘Forward direction’, ‘Backword direction’) I am trying to draw the backward and forward points of the slow invariant manifold (SIM) from the equilibrium point using the following code of Intrinsic low dimensional manifold (ILDM), but didn’t get all backward points. could anyone identify the mistake.
by using below code i am getting following graph which is not plotting the backward points
i am trying to get following result, but unfortunately there is a mistake in my code.
code:
% A + Z <=====> AZ
% AZ + B <=====> AB + Z
% Let A=c1, B=c2, Z=c3, AZ=c4 and AB=c5
% c1 + c3 <=====> c4 % c4 + c2 <=====> c5 + c3
clc;
clear
syms c1 c2 c3 c4 c5 x1 x2
syms k1p k2p k1n k2n %positive and negative k’s
%Stoichiometric Vectors
r1 = [-1; 0; -1; 1; 0];
r2 = [0; -1; 1; -1; 1];
%Parameters
k1p=1; k2p=0.5; k3p=1 ;
EP=[.5 .1 .1 .4 .1]; %Equilibrium Point
C1=EP(1); C2=EP(2); C3=EP(3); C4=EP(4); C5=EP(5);
%Finding k1n, k2n (((((((((((((((((((((((((((((((( %Reaction Rates
w1 = k1p*C1*C3 – k1n*C4;
w2 = k2p*C4*C2 – k2n*C5*C3;
%solving for k1n and k2n
k1n=solve(w1==0, k1n);
k2n=solve(w2==0, k2n);
%)))))))))))))))))))))))))))))))))))))))))))))))))
%Molecular Matrix[1 0 0 1 1; 0 1 0 0 1; 0 0 1 1 0]
bA = C1+C3+C4; %for A
bB = C2+C5; %for B
bZ = C3+C4; %for Z
% Reducing the system for species c1=A, c4=AZ;
c3 = bZ – c4;
c5 = bA – c1 – c4;
c2 = bB – c5;
%Reaction Rates
w1 = k1p*c1*c3 – k1n*c4;
w2 = k2p*c4*c2 – k2n*c5*c3;
%Using Law of Conservation of Mass
G = r1*w1 + r2*w2;
%Reduced System
F = [G(1); G(4)];
F = subs(F,[c1,c4],[x1,x2]);
EP = [C1; C4];
m=20; n=17; %no of points forward and backward to the equilibrium point
h=0.03; %constant increment
%Finding points above EP
P=EP; r=P;
for forward = 1:m
J = ILDM1D_jacobian(F,r);
b = ILDM1D_slowest(J);
r = P + h*b;
Q = ILDM1D_projection(J);
P = ILDM1D_manifold(Q,F,r);
allForward(forward,:) = P; % all Forward matrix stores all forward points
end
%Finding points below EP
P=EP; r=P;
for backward =1:n
J= ILDM1D_jacobian (F,r);
b = ILDM1D_slowest (J);
r = P + h*b;
Q= ILDM1D_projection (J);
ILDM1D_manifold (Q,F,r);
allBackward(backward,:) = P;
%allBackward matrix stores all backward points
end
%Plotting
plot (EP (1),EP (2), ‘ks’);hold on;
plot (allForward(:,1),allForward(:,2),’+k-‘);
plot (allBackward(:,2),allBackward(:,2),’*k-‘);
grid on;
axis ([0 1 0 .7]);
xlabel (‘A’); ylabel (‘AZ’);
legend(‘Eguilibrium point’, ‘Forward direction’, ‘Backword direction’) manifold, plot, intrinsic low dimensional manifold, chemical kinetics MATLAB Answers — New Questions
issue in approximation of wave speed of propagation
0
im exploring Fisher KPP equation and diffrent numerical methods to study its behaviour specifically travelling waves and speed of propagation
here is the code in Matlab where iuse finite difference scheme:
C = 0.05; % Courant number
D = 1; % Diffusion coefficient
r = 1; % Reaction rate
Lx = 10; % Width of the domain
Ly = 10; % Height of the domain
nx = 51; % Number of grid points in x-direction
ny = 51; % Number of grid points in y-direction
nt = 5000; % Number of time steps
dx = Lx / (nx-1); % Spacing of grid in x-direction
dy = Ly / (ny-1); % Spacing of grid in y-direction
dt = C * dx; % Time step size
% Initialize concentration profile
un = zeros(ny, nx);
x = linspace(-Lx/2, Lx/2, nx);
y = linspace(-Ly/2, Ly/2, ny);
[X, Y] = meshgrid(x, y);
% Set initial condition
initial_condition = (X.^2 + 2*Y.^2 < 0.25);
un = 0.5 * initial_condition;
% Initialize matrix to save solutions over time
U = zeros(nt, ny, nx);
U(1,:,:) = un;
% Loop over time steps to solve the PDE
for n = 1:nt
uc = un;
% Update concentration profile using finite difference method
for i = 2:nx-1
for j = 2:ny-1
un(j, i) = uc(j, i) + …
dt * (uc(j-1, i) – 2 * uc(j, i) + uc(j+1, i))/dy^2 + …
dt * (uc(j, i-1) – 2 * uc(j, i) + uc(j, i+1))/dx^2 + …
dt * uc(j, i) * (1 – uc(j,i));
end
end
% Apply Dirichlet boundary conditions
un(1,:) = 0;
un(end,:) = 0;
un(:,1) = 0;
un(:,end) = 0;
% Store solution
U(n+1,:,:) = un;
end
% Initialize arrays to store pairs of (x, t)
x_values = [];
t_values = [];
% Loop over time steps
for ti = 1:nt
for tj = ti+1:nt % to avoid comparing the same time step twice
% Extract concentration profiles at times ti and tj
ui = squeeze(U(ti,:,:));
uj = squeeze(U(tj,:,:));
% Find pairs (xi, xj) where ui(xi, y) = uj(xj, y) for all y
[xi, xj] = find(all(abs(ui – uj) < 1e-2, 1)); % tolerance for numerical solution
% Store pairs (xi, ti) and (xj, tj)
for k = 1:length(xi)
x_values = [x_values; x(xi(k)), x(xj(k))];
t_values = [t_values; ti, tj];
end
end
end
% Plot pairs of (ti, tj) against (xi, xj)
figure;
plot(t_values, x_values, ‘o’);
xlabel(‘Temps’);
ylabel(‘Position x’);
title(‘Paires (ti, tj) où u(xi, y, ti) = u(xj, y, tj) pour tout y’);
grid on;
i’m expecting that the slope graph equal or large than 2 but with this code i dont get that ? what is the issue? the slope graph her is the approximate speed whixh u calculte by :c=(x_j-x_i)/(t_j-t_i) such that u(x_i,y,t_i)=u(x_j,y,t_j)can you please tell me the issue and if you have another suggestion please tell me0
im exploring Fisher KPP equation and diffrent numerical methods to study its behaviour specifically travelling waves and speed of propagation
here is the code in Matlab where iuse finite difference scheme:
C = 0.05; % Courant number
D = 1; % Diffusion coefficient
r = 1; % Reaction rate
Lx = 10; % Width of the domain
Ly = 10; % Height of the domain
nx = 51; % Number of grid points in x-direction
ny = 51; % Number of grid points in y-direction
nt = 5000; % Number of time steps
dx = Lx / (nx-1); % Spacing of grid in x-direction
dy = Ly / (ny-1); % Spacing of grid in y-direction
dt = C * dx; % Time step size
% Initialize concentration profile
un = zeros(ny, nx);
x = linspace(-Lx/2, Lx/2, nx);
y = linspace(-Ly/2, Ly/2, ny);
[X, Y] = meshgrid(x, y);
% Set initial condition
initial_condition = (X.^2 + 2*Y.^2 < 0.25);
un = 0.5 * initial_condition;
% Initialize matrix to save solutions over time
U = zeros(nt, ny, nx);
U(1,:,:) = un;
% Loop over time steps to solve the PDE
for n = 1:nt
uc = un;
% Update concentration profile using finite difference method
for i = 2:nx-1
for j = 2:ny-1
un(j, i) = uc(j, i) + …
dt * (uc(j-1, i) – 2 * uc(j, i) + uc(j+1, i))/dy^2 + …
dt * (uc(j, i-1) – 2 * uc(j, i) + uc(j, i+1))/dx^2 + …
dt * uc(j, i) * (1 – uc(j,i));
end
end
% Apply Dirichlet boundary conditions
un(1,:) = 0;
un(end,:) = 0;
un(:,1) = 0;
un(:,end) = 0;
% Store solution
U(n+1,:,:) = un;
end
% Initialize arrays to store pairs of (x, t)
x_values = [];
t_values = [];
% Loop over time steps
for ti = 1:nt
for tj = ti+1:nt % to avoid comparing the same time step twice
% Extract concentration profiles at times ti and tj
ui = squeeze(U(ti,:,:));
uj = squeeze(U(tj,:,:));
% Find pairs (xi, xj) where ui(xi, y) = uj(xj, y) for all y
[xi, xj] = find(all(abs(ui – uj) < 1e-2, 1)); % tolerance for numerical solution
% Store pairs (xi, ti) and (xj, tj)
for k = 1:length(xi)
x_values = [x_values; x(xi(k)), x(xj(k))];
t_values = [t_values; ti, tj];
end
end
end
% Plot pairs of (ti, tj) against (xi, xj)
figure;
plot(t_values, x_values, ‘o’);
xlabel(‘Temps’);
ylabel(‘Position x’);
title(‘Paires (ti, tj) où u(xi, y, ti) = u(xj, y, tj) pour tout y’);
grid on;
i’m expecting that the slope graph equal or large than 2 but with this code i dont get that ? what is the issue? the slope graph her is the approximate speed whixh u calculte by :c=(x_j-x_i)/(t_j-t_i) such that u(x_i,y,t_i)=u(x_j,y,t_j)can you please tell me the issue and if you have another suggestion please tell me 0
im exploring Fisher KPP equation and diffrent numerical methods to study its behaviour specifically travelling waves and speed of propagation
here is the code in Matlab where iuse finite difference scheme:
C = 0.05; % Courant number
D = 1; % Diffusion coefficient
r = 1; % Reaction rate
Lx = 10; % Width of the domain
Ly = 10; % Height of the domain
nx = 51; % Number of grid points in x-direction
ny = 51; % Number of grid points in y-direction
nt = 5000; % Number of time steps
dx = Lx / (nx-1); % Spacing of grid in x-direction
dy = Ly / (ny-1); % Spacing of grid in y-direction
dt = C * dx; % Time step size
% Initialize concentration profile
un = zeros(ny, nx);
x = linspace(-Lx/2, Lx/2, nx);
y = linspace(-Ly/2, Ly/2, ny);
[X, Y] = meshgrid(x, y);
% Set initial condition
initial_condition = (X.^2 + 2*Y.^2 < 0.25);
un = 0.5 * initial_condition;
% Initialize matrix to save solutions over time
U = zeros(nt, ny, nx);
U(1,:,:) = un;
% Loop over time steps to solve the PDE
for n = 1:nt
uc = un;
% Update concentration profile using finite difference method
for i = 2:nx-1
for j = 2:ny-1
un(j, i) = uc(j, i) + …
dt * (uc(j-1, i) – 2 * uc(j, i) + uc(j+1, i))/dy^2 + …
dt * (uc(j, i-1) – 2 * uc(j, i) + uc(j, i+1))/dx^2 + …
dt * uc(j, i) * (1 – uc(j,i));
end
end
% Apply Dirichlet boundary conditions
un(1,:) = 0;
un(end,:) = 0;
un(:,1) = 0;
un(:,end) = 0;
% Store solution
U(n+1,:,:) = un;
end
% Initialize arrays to store pairs of (x, t)
x_values = [];
t_values = [];
% Loop over time steps
for ti = 1:nt
for tj = ti+1:nt % to avoid comparing the same time step twice
% Extract concentration profiles at times ti and tj
ui = squeeze(U(ti,:,:));
uj = squeeze(U(tj,:,:));
% Find pairs (xi, xj) where ui(xi, y) = uj(xj, y) for all y
[xi, xj] = find(all(abs(ui – uj) < 1e-2, 1)); % tolerance for numerical solution
% Store pairs (xi, ti) and (xj, tj)
for k = 1:length(xi)
x_values = [x_values; x(xi(k)), x(xj(k))];
t_values = [t_values; ti, tj];
end
end
end
% Plot pairs of (ti, tj) against (xi, xj)
figure;
plot(t_values, x_values, ‘o’);
xlabel(‘Temps’);
ylabel(‘Position x’);
title(‘Paires (ti, tj) où u(xi, y, ti) = u(xj, y, tj) pour tout y’);
grid on;
i’m expecting that the slope graph equal or large than 2 but with this code i dont get that ? what is the issue? the slope graph her is the approximate speed whixh u calculte by :c=(x_j-x_i)/(t_j-t_i) such that u(x_i,y,t_i)=u(x_j,y,t_j)can you please tell me the issue and if you have another suggestion please tell me finite difference scheme, numerical analysis MATLAB Answers — New Questions
How can I display the satelliteScenarioViewer in an appdesigner panel or just in my app instead of coming up a new window ?
I’m woking on appdesigner and I want to display the satelliteScenarioViewer in a panel. But I find it difficult. The satelliteScenarioViewer always comes up with a new window. I wander if someone knows how to solve this problem.I’m woking on appdesigner and I want to display the satelliteScenarioViewer in a panel. But I find it difficult. The satelliteScenarioViewer always comes up with a new window. I wander if someone knows how to solve this problem. I’m woking on appdesigner and I want to display the satelliteScenarioViewer in a panel. But I find it difficult. The satelliteScenarioViewer always comes up with a new window. I wander if someone knows how to solve this problem. appdesigner, satellitescenarioviewer MATLAB Answers — New Questions
Tabulating the data obtained for my Matlab code
With the code I stated below, I obtain 2 column graphic data as x and y. The data I obtained appear separately on the right. One writes as a column, the other as a row. I would like help in updating my code to create a txt or Excel file with these two data as columns from top to bottom.
The data I obtained look like this, separately, one as a column and the other as a graph. I want it to give me this data as columns in txt or excel.
I upload the data I use for the code to work as a txt file.
data = readmatrix(‘Naca LD0006 6R.txt’);
f = fit(data(:,1), data(:,2),’smoothingspline’,’SmoothingParam’,0.3);
xi = -15:1:18; % or -15:0.5:18 or whatever
yi = f(xi);
figure
plot(f,data(:,1),data(:,2))
hold on
plot(xi,yi,’o’,’MarkerFaceColor’,’g’,’DisplayName’,’1° intervals’)
set(get(gca(),’Legend’),’Location’,’best’);With the code I stated below, I obtain 2 column graphic data as x and y. The data I obtained appear separately on the right. One writes as a column, the other as a row. I would like help in updating my code to create a txt or Excel file with these two data as columns from top to bottom.
The data I obtained look like this, separately, one as a column and the other as a graph. I want it to give me this data as columns in txt or excel.
I upload the data I use for the code to work as a txt file.
data = readmatrix(‘Naca LD0006 6R.txt’);
f = fit(data(:,1), data(:,2),’smoothingspline’,’SmoothingParam’,0.3);
xi = -15:1:18; % or -15:0.5:18 or whatever
yi = f(xi);
figure
plot(f,data(:,1),data(:,2))
hold on
plot(xi,yi,’o’,’MarkerFaceColor’,’g’,’DisplayName’,’1° intervals’)
set(get(gca(),’Legend’),’Location’,’best’); With the code I stated below, I obtain 2 column graphic data as x and y. The data I obtained appear separately on the right. One writes as a column, the other as a row. I would like help in updating my code to create a txt or Excel file with these two data as columns from top to bottom.
The data I obtained look like this, separately, one as a column and the other as a graph. I want it to give me this data as columns in txt or excel.
I upload the data I use for the code to work as a txt file.
data = readmatrix(‘Naca LD0006 6R.txt’);
f = fit(data(:,1), data(:,2),’smoothingspline’,’SmoothingParam’,0.3);
xi = -15:1:18; % or -15:0.5:18 or whatever
yi = f(xi);
figure
plot(f,data(:,1),data(:,2))
hold on
plot(xi,yi,’o’,’MarkerFaceColor’,’g’,’DisplayName’,’1° intervals’)
set(get(gca(),’Legend’),’Location’,’best’); #matlab #excel #txt #naca MATLAB Answers — New Questions
Write a MATLAB program which will ask the user for a number. If the number is equal to two times a predefined number, the program should print out a welcome message. Otherwise
SolveSolve Solve #fast, homework, do it for me MATLAB Answers — New Questions
What happens to cleared custom `handle` objects?
I know that MATLAB exposes the handle class which alllows one to define passed-by-reference objects like:
classdef ConcreteHandle < handle
properties
UserData = []
end
methods
function self = ConcreteHandle(data)
arguments
data = []
end
self.UserData = data;
end
end
end
How does the behaviour of this class differ from the existing graphical handle objects? For example:
fh = figure;
clear fh
Doesn’t delete the figure (but close(fh) or delete(fh) will). Even after the reference to fh is cleared you can still recover it with built-in utilities like findall():
fh = findall(0, ‘Type’, ‘Figure’);
What happens if I construct an instance of my custom class:
c = ConcreteHandle();
clear c
Is c (and the data in c.UserData) handed over to the gargabe collector? Does there exist an equivilant call to findall() or a similar utility that lets me find c?I know that MATLAB exposes the handle class which alllows one to define passed-by-reference objects like:
classdef ConcreteHandle < handle
properties
UserData = []
end
methods
function self = ConcreteHandle(data)
arguments
data = []
end
self.UserData = data;
end
end
end
How does the behaviour of this class differ from the existing graphical handle objects? For example:
fh = figure;
clear fh
Doesn’t delete the figure (but close(fh) or delete(fh) will). Even after the reference to fh is cleared you can still recover it with built-in utilities like findall():
fh = findall(0, ‘Type’, ‘Figure’);
What happens if I construct an instance of my custom class:
c = ConcreteHandle();
clear c
Is c (and the data in c.UserData) handed over to the gargabe collector? Does there exist an equivilant call to findall() or a similar utility that lets me find c? I know that MATLAB exposes the handle class which alllows one to define passed-by-reference objects like:
classdef ConcreteHandle < handle
properties
UserData = []
end
methods
function self = ConcreteHandle(data)
arguments
data = []
end
self.UserData = data;
end
end
end
How does the behaviour of this class differ from the existing graphical handle objects? For example:
fh = figure;
clear fh
Doesn’t delete the figure (but close(fh) or delete(fh) will). Even after the reference to fh is cleared you can still recover it with built-in utilities like findall():
fh = findall(0, ‘Type’, ‘Figure’);
What happens if I construct an instance of my custom class:
c = ConcreteHandle();
clear c
Is c (and the data in c.UserData) handed over to the gargabe collector? Does there exist an equivilant call to findall() or a similar utility that lets me find c? handles, graphics MATLAB Answers — New Questions
How to code the equation below?
I have an equation to code
To sigmaI, I is used, which is a 512*512 matrix. Also I need to calculate BER also. The equation is
The code that I wrote is,
clc;close all;clear all;
lambda = 532;
k = 2*pi/lambda;
z=[1.03700000000000 1.39100000000000 1.59800000000000 1.84800000000000 1.88900000000000 2.01400000000000 2.34800000000000 2.45100000000000 2.57600000000000 2.72200000000000 2.78500000000000 2.88900000000000 2.97200000000000 3.16000000000000 3.20200000000000 3.36900000000000 3.41100000000000 3.51500000000000 3.55700000000000 3.57700000000000 3.66100000000000 3.66100000000000 3.68100000000000 3.70200000000000 3.74400000000000 3.82800000000000 3.93200000000000 4.05700000000000 4.18200000000000 4.55600000000000 4.70200000000000 4.91000000000000 5.01500000000000 5.16100000000000 5.24400000000000 5.26500000000000 5.28600000000000 5.28600000000000 5.28600000000000 5.24400000000000 5.26400000000000 5.22300000000000 5.39000000000000 5.57700000000000 5.72200000000000 5.93100000000000 6.16000000000000 6.41000000000000 6.63800000000000 6.88800000000000 7.03400000000000 7.24200000000000 7.34700000000000 7.45100000000000 7.53400000000000 7.63900000000000 7.68000000000000 7.80500000000000 7.82600000000000 7.95100000000000 8.09700000000000 8.20100000000000 8.30600000000000 8.47200000000000 8.66000000000000 8.82600000000000 8.97200000000000 9.07700000000000 9.18100000000000 9.24300000000000 9.28400000000000 9.32600000000000 9.34700000000000 9.34700000000000 9.36800000000000 9.36800000000000 9.40900000000000 9.47200000000000 9.51400000000000 9.57600000000000 9.65900000000000 9.74200000000000 9.84600000000000 9.99200000000000 10.1790000000000 10.5130000000000 10.5760000000000 10.9710000000000 11.1380000000000 11.3260000000000 11.4090000000000 11.4710000000000 11.5130000000000 11.5550000000000 11.6170000000000 11.7000000000000 11.8250000000000 11.8870000000000 12.2830000000000 12.4910000000000 12.6370000000000 12.8040000000000 12.9490000000000 13.1150000000000 13.2610000000000 13.5540000000000 13.6790000000000 13.8240000000000 13.9080000000000 14.3040000000000 14.3870000000000 14.4910000000000 14.5740000000000 14.6370000000000 14.7620000000000 14.8450000000000 14.9490000000000 15.0320000000000 15.1370000000000 15.2820000000000 15.3650000000000 15.5320000000000 15.6160000000000 15.7410000000000 15.8870000000000 16.0530000000000 16.1570000000000 16.3650000000000 16.5940000000000 16.7400000000000 16.8650000000000 16.9280000000000 17.0530000000000 17.0950000000000 17.1780000000000 17.2200000000000 17.3030000000000 17.3440000000000 17.5530000000000 17.6980000000000 17.8020000000000 17.9900000000000 18.1360000000000 18.3650000000000 18.5740000000000 18.8030000000000 18.9900000000000 19.1980000000000 19.5100000000000 19.6560000000000 19.8430000000000 19.9690000000000 20.0940000000000 20.1760000000000 20.3220000000000 20.4680000000000 20.5930000000000 20.7590000000000 20.9050000000000 21.0510000000000 21.1970000000000 21.4260000000000 21.5920000000000 21.7170000000000 21.9050000000000 22.0300000000000 22.2180000000000 22.3430000000000 22.5510000000000 22.8420000000000 23.0920000000000 23.1960000000000 23.4250000000000 23.5920000000000 23.7170000000000 23.8630000000000 24.0500000000000 24.1960000000000 24.3210000000000 24.5910000000000 24.7370000000000 24.8620000000000 25.0490000000000 25.2580000000000 25.5490000000000 25.7160000000000 25.8830000000000 26.0910000000000 26.2370000000000 26.3200000000000 26.6960000000000 27.4040000000000 27.6120000000000 27.7790000000000 27.9870000000000 28.1540000000000 28.3620000000000 28.5280000000000 28.6950000000000 28.8830000000000 29.2370000000000 29.4450000000000 29.5490000000000 29.7990000000000 29.9650000000000 30.1320000000000 30.3190000000000 30.5070000000000 30.6950000000000 30.8200000000000 30.9860000000000 31.1320000000000 31.3200000000000 31.3820000000000 31.4870000000000 31.5910000000000 31.7580000000000 31.8610000000000 31.9870000000000 32.0700000000000 32.3610000000000 32.4860000000000 32.6320000000000 32.8810000000000 33.0060000000000 33.0480000000000 33.0690000000000 33.0900000000000 33.0900000000000 33.0690000000000 33.0270000000000 32.9240000000000 32.9030000000000 32.8610000000000 32.8820000000000 32.9030000000000 32.9660000000000 33.0490000000000 33.0910000000000 33.1740000000000 33.2570000000000 33.3200000000000 33.3820000000000 33.4660000000000 33.4440000000000 33.4230000000000 33.4020000000000 33.4230000000000 33.3810000000000 33.4020000000000 33.4020000000000 33.4020000000000 33.4020000000000 33.4020000000000 33.4440000000000 33.4640000000000 33.5270000000000 33.5270000000000 33.6110000000000 33.6520000000000 33.6730000000000 33.6930000000000 33.6740000000000 33.6740000000000 33.6320000000000 33.5280000000000 33.4650000000000 33.3820000000000 33.4030000000000 33.3610000000000 33.3400000000000 33.3200000000000 33.2570000000000 33.3410000000000 33.3820000000000 33.4240000000000 33.4440000000000 33.4650000000000 33.4440000000000 33.5060000000000 33.5060000000000 33.5480000000000 33.5480000000000 33.5480000000000 33.5690000000000 33.6100000000000 33.7350000000000 33.8390000000000 33.9220000000000 34.0270000000000 34.1310000000000 34.3180000000000 34.5480000000000 34.7350000000000 34.8810000000000 35.0480000000000 35.2140000000000 35.4440000000000 35.5900000000000 35.7150000000000 36.0690000000000 36.1730000000000 36.3400000000000 36.5270000000000 36.5900000000000 36.7150000000000 36.9640000000000 37.0270000000000 37.1730000000000 37.3190000000000 37.4640000000000 37.6100000000000 37.7770000000000 37.9230000000000 38.0680000000000 38.1520000000000 38.2980000000000 38.4230000000000 38.5480000000000 38.5480000000000 38.5680000000000 38.6100000000000 38.6520000000000 38.7140000000000 38.7770000000000 38.9230000000000 39.0900000000000 39.2360000000000 39.3810000000000 39.7140000000000 39.8390000000000 40.0060000000000 40.1310000000000 40.2560000000000 40.3810000000000 40.4640000000000 40.5270000000000 40.6100000000000 40.6930000000000 40.7550000000000 40.8800000000000 41.0260000000000 41.1300000000000 41.2350000000000 41.3810000000000 41.5260000000000 41.6510000000000 41.7560000000000 41.9220000000000 42.0890000000000 42.2140000000000 42.4850000000000 42.6520000000000 42.8600000000000 42.9650000000000 43.1520000000000 43.2560000000000 43.4020000000000 43.5060000000000 43.7140000000000 43.7560000000000 43.8390000000000 43.9010000000000 43.9850000000000 44.1100000000000 44.2140000000000 44.3380000000000 44.5470000000000 44.6720000000000 44.8380000000000 44.9630000000000 45.1300000000000 45.3380000000000 45.4420000000000 45.6500000000000 45.7540000000000 46.0870000000000 46.1910000000000 46.3580000000000 46.4620000000000 46.5460000000000 46.6290000000000 46.6710000000000 46.7540000000000 46.8170000000000 46.8790000000000 47.0460000000000 47.1080000000000 47.2130000000000 47.3590000000000 47.6710000000000 47.9000000000000 48.0660000000000 48.2540000000000 48.4210000000000 48.5460000000000 48.7120000000000 48.7950000000000 48.8160000000000 48.9210000000000 48.9830000000000 49.0250000000000 49.0670000000000 49.0870000000000 49.2120000000000 49.2960000000000 49.4210000000000 49.4840000000000 49.7120000000000 49.9410000000000 50.0450000000000 50.6070000000000 50.7320000000000 50.8370000000000 50.9200000000000 51.0040000000000 51.1290000000000 51.1910000000000 51.2960000000000 51.4210000000000 51.4830000000000 51.5250000000000 51.6080000000000 51.7130000000000 51.7540000000000 51.8170000000000 51.9210000000000 52.0040000000000 52.0660000000000 52.1910000000000 52.2950000000000 52.4620000000000 52.5450000000000 52.6910000000000 52.8160000000000 53.0650000000000 53.2320000000000 53.2950000000000 53.3980000000000 53.4400000000000 53.5240000000000 53.6280000000000 53.6490000000000 53.7530000000000 53.8570000000000 53.9200000000000 54.0660000000000 54.1490000000000 54.2730000000000 54.4190000000000 54.5230000000000 54.6280000000000 54.7320000000000 54.8160000000000 54.8990000000000 55.0240000000000 55.0860000000000 55.1490000000000 55.2320000000000 55.2950000000000 55.4200000000000 55.5030000000000 55.7110000000000 55.8150000000000 56.0650000000000 56.1910000000000 56.4200000000000 56.5030000000000 56.6070000000000 56.6910000000000 56.7530000000000 56.8570000000000 56.9830000000000 57.3160000000000 57.4610000000000 57.6280000000000 57.7730000000000 57.9610000000000 58.1270000000000 58.5020000000000 58.6690000000000 58.8150000000000 58.9190000000000 59.0650000000000 59.1690000000000 59.2520000000000 59.4190000000000 59.4190000000000 59.5230000000000 59.5440000000000 59.6280000000000 59.7530000000000 59.8160000000000 59.9410000000000 60.1490000000000 60.2950000000000 60.4610000000000 61.1270000000000 61.2530000000000 61.5020000000000 61.9390000000000 62.0850000000000 62.2100000000000 62.3770000000000 62.7100000000000 62.8980000000000 63.0440000000000 63.2940000000000 63.4820000000000 63.7110000000000 63.8980000000000 64.1060000000000 64.3150000000000 64.5020000000000 64.6900000000000 64.8770000000000 65.0850000000000 65.2100000000000 65.3150000000000 65.4400000000000 65.6270000000000 65.7310000000000 65.8560000000000 66.0230000000000 66.1270000000000 66.2510000000000 66.3560000000000 66.6470000000000 66.7510000000000 66.8760000000000 66.9380000000000 67.1890000000000 67.3140000000000 67.3970000000000 67.5220000000000 67.5640000000000 67.7310000000000 67.8560000000000 67.9810000000000 68.0650000000000 68.1480000000000 68.2730000000000 68.3980000000000 68.4810000000000 68.6060000000000 68.6680000000000 68.8140000000000 68.8970000000000 69.0220000000000 69.2090000000000 69.2920000000000 69.6460000000000 69.6670000000000 69.8340000000000 70.0840000000000 70.1890000000000 70.3140000000000 70.4810000000000 70.6050000000000 70.7510000000000 70.8760000000000 71.0430000000000 71.1470000000000 71.2720000000000 71.4390000000000 71.7100000000000 71.8770000000000 71.9810000000000 72.1470000000000 72.2720000000000 72.3550000000000 72.5010000000000 72.5430000000000 72.6470000000000 72.7520000000000 72.8140000000000 72.9610000000000 73.0440000000000 73.1690000000000 73.3140000000000 73.4810000000000 74.0430000000000 74.1890000000000 74.3980000000000 74.5220000000000 74.6050000000000 74.7100000000000 74.7300000000000 74.7720000000000 74.8130000000000 74.8330000000000 74.8960000000000 74.9370000000000 75.0210000000000 75.0620000000000 75.2080000000000 75.3540000000000 75.7080000000000 75.8750000000000 76.0630000000000 76.2300000000000 76.4380000000000 76.5430000000000 76.7090000000000 76.8760000000000 77.0010000000000 77.1260000000000 77.2720000000000 77.3770000000000 77.4800000000000 77.6050000000000 77.8550000000000 77.9600000000000 78.0640000000000 78.1060000000000 78.2100000000000 78.3970000000000 78.5220000000000 78.6270000000000 78.8550000000000 79.0430000000000 79.2300000000000 79.6470000000000 79.8760000000000 80.5220000000000 80.6260000000000 80.7930000000000 80.8550000000000 80.8970000000000 80.9180000000000 80.9390000000000 80.9810000000000 81.0430000000000 81.1270000000000 81.2730000000000 81.4600000000000 81.6270000000000 81.8350000000000 82.1260000000000 82.6260000000000 82.8760000000000 83.1050000000000 83.2720000000000 83.4390000000000 83.5850000000000 83.6890000000000 83.7310000000000 83.7100000000000 83.6890000000000 83.6890000000000 83.7100000000000 83.8350000000000 83.9180000000000 84.0850000000000 84.4600000000000 84.6890000000000 84.9180000000000 85.3970000000000 85.5220000000000 85.6260000000000 85.8560000000000 85.8550000000000 85.8560000000000 85.8760000000000 85.9380000000000 85.9390000000000 86.0430000000000 86.1470000000000 86.2510000000000 86.4180000000000 86.6470000000000 86.8550000000000 87.0850000000000 87.3340000000000 87.5630000000000 87.7720000000000 88.0630000000000 88.1890000000000 88.4390000000000 88.5430000000000 88.6480000000000 88.6480000000000 88.7100000000000 88.7730000000000 88.8770000000000 88.8980000000000 89.0010000000000 89.1050000000000 89.2930000000000 89.4180000000000 89.6470000000000 89.7930000000000 90.0010000000000 90.2100000000000 90.4180000000000 90.6060000000000 90.7100000000000 90.8770000000000 91.0640000000000 91.1680000000000 91.2720000000000 91.3560000000000 91.4180000000000 91.5220000000000 91.6470000000000 91.7310000000000 91.8350000000000 91.9180000000000 92.1060000000000 92.2310000000000 92.3760000000000 92.6060000000000 92.7930000000000 93.0010000000000 93.4180000000000 93.6470000000000 93.8970000000000 94.4180000000000 94.5840000000000 94.7300000000000 95.0220000000000 95.1890000000000 95.3140000000000 95.5220000000000 95.8140000000000 95.9180000000000 96.0640000000000 96.2300000000000 96.3130000000000 96.5010000000000 96.6260000000000 96.7720000000000 96.8560000000000 97.0230000000000 97.1680000000000 97.2720000000000 97.3970000000000 97.5430000000000 97.6680000000000 97.7520000000000 97.8770000000000 97.9600000000000 98.0650000000000 98.3360000000000 98.4190000000000 98.5230000000000 98.6070000000000 98.7320000000000 98.8150000000000 98.9190000000000 99.1060000000000 99.2520000000000 99.4190000000000 99.5860000000000 99.7940000000000 99.9190000000000 100.044000000000];
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
A1
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 whether the codes for SigmaI and BER is correct.I have an equation to code
To sigmaI, I is used, which is a 512*512 matrix. Also I need to calculate BER also. The equation is
The code that I wrote is,
clc;close all;clear all;
lambda = 532;
k = 2*pi/lambda;
z=[1.03700000000000 1.39100000000000 1.59800000000000 1.84800000000000 1.88900000000000 2.01400000000000 2.34800000000000 2.45100000000000 2.57600000000000 2.72200000000000 2.78500000000000 2.88900000000000 2.97200000000000 3.16000000000000 3.20200000000000 3.36900000000000 3.41100000000000 3.51500000000000 3.55700000000000 3.57700000000000 3.66100000000000 3.66100000000000 3.68100000000000 3.70200000000000 3.74400000000000 3.82800000000000 3.93200000000000 4.05700000000000 4.18200000000000 4.55600000000000 4.70200000000000 4.91000000000000 5.01500000000000 5.16100000000000 5.24400000000000 5.26500000000000 5.28600000000000 5.28600000000000 5.28600000000000 5.24400000000000 5.26400000000000 5.22300000000000 5.39000000000000 5.57700000000000 5.72200000000000 5.93100000000000 6.16000000000000 6.41000000000000 6.63800000000000 6.88800000000000 7.03400000000000 7.24200000000000 7.34700000000000 7.45100000000000 7.53400000000000 7.63900000000000 7.68000000000000 7.80500000000000 7.82600000000000 7.95100000000000 8.09700000000000 8.20100000000000 8.30600000000000 8.47200000000000 8.66000000000000 8.82600000000000 8.97200000000000 9.07700000000000 9.18100000000000 9.24300000000000 9.28400000000000 9.32600000000000 9.34700000000000 9.34700000000000 9.36800000000000 9.36800000000000 9.40900000000000 9.47200000000000 9.51400000000000 9.57600000000000 9.65900000000000 9.74200000000000 9.84600000000000 9.99200000000000 10.1790000000000 10.5130000000000 10.5760000000000 10.9710000000000 11.1380000000000 11.3260000000000 11.4090000000000 11.4710000000000 11.5130000000000 11.5550000000000 11.6170000000000 11.7000000000000 11.8250000000000 11.8870000000000 12.2830000000000 12.4910000000000 12.6370000000000 12.8040000000000 12.9490000000000 13.1150000000000 13.2610000000000 13.5540000000000 13.6790000000000 13.8240000000000 13.9080000000000 14.3040000000000 14.3870000000000 14.4910000000000 14.5740000000000 14.6370000000000 14.7620000000000 14.8450000000000 14.9490000000000 15.0320000000000 15.1370000000000 15.2820000000000 15.3650000000000 15.5320000000000 15.6160000000000 15.7410000000000 15.8870000000000 16.0530000000000 16.1570000000000 16.3650000000000 16.5940000000000 16.7400000000000 16.8650000000000 16.9280000000000 17.0530000000000 17.0950000000000 17.1780000000000 17.2200000000000 17.3030000000000 17.3440000000000 17.5530000000000 17.6980000000000 17.8020000000000 17.9900000000000 18.1360000000000 18.3650000000000 18.5740000000000 18.8030000000000 18.9900000000000 19.1980000000000 19.5100000000000 19.6560000000000 19.8430000000000 19.9690000000000 20.0940000000000 20.1760000000000 20.3220000000000 20.4680000000000 20.5930000000000 20.7590000000000 20.9050000000000 21.0510000000000 21.1970000000000 21.4260000000000 21.5920000000000 21.7170000000000 21.9050000000000 22.0300000000000 22.2180000000000 22.3430000000000 22.5510000000000 22.8420000000000 23.0920000000000 23.1960000000000 23.4250000000000 23.5920000000000 23.7170000000000 23.8630000000000 24.0500000000000 24.1960000000000 24.3210000000000 24.5910000000000 24.7370000000000 24.8620000000000 25.0490000000000 25.2580000000000 25.5490000000000 25.7160000000000 25.8830000000000 26.0910000000000 26.2370000000000 26.3200000000000 26.6960000000000 27.4040000000000 27.6120000000000 27.7790000000000 27.9870000000000 28.1540000000000 28.3620000000000 28.5280000000000 28.6950000000000 28.8830000000000 29.2370000000000 29.4450000000000 29.5490000000000 29.7990000000000 29.9650000000000 30.1320000000000 30.3190000000000 30.5070000000000 30.6950000000000 30.8200000000000 30.9860000000000 31.1320000000000 31.3200000000000 31.3820000000000 31.4870000000000 31.5910000000000 31.7580000000000 31.8610000000000 31.9870000000000 32.0700000000000 32.3610000000000 32.4860000000000 32.6320000000000 32.8810000000000 33.0060000000000 33.0480000000000 33.0690000000000 33.0900000000000 33.0900000000000 33.0690000000000 33.0270000000000 32.9240000000000 32.9030000000000 32.8610000000000 32.8820000000000 32.9030000000000 32.9660000000000 33.0490000000000 33.0910000000000 33.1740000000000 33.2570000000000 33.3200000000000 33.3820000000000 33.4660000000000 33.4440000000000 33.4230000000000 33.4020000000000 33.4230000000000 33.3810000000000 33.4020000000000 33.4020000000000 33.4020000000000 33.4020000000000 33.4020000000000 33.4440000000000 33.4640000000000 33.5270000000000 33.5270000000000 33.6110000000000 33.6520000000000 33.6730000000000 33.6930000000000 33.6740000000000 33.6740000000000 33.6320000000000 33.5280000000000 33.4650000000000 33.3820000000000 33.4030000000000 33.3610000000000 33.3400000000000 33.3200000000000 33.2570000000000 33.3410000000000 33.3820000000000 33.4240000000000 33.4440000000000 33.4650000000000 33.4440000000000 33.5060000000000 33.5060000000000 33.5480000000000 33.5480000000000 33.5480000000000 33.5690000000000 33.6100000000000 33.7350000000000 33.8390000000000 33.9220000000000 34.0270000000000 34.1310000000000 34.3180000000000 34.5480000000000 34.7350000000000 34.8810000000000 35.0480000000000 35.2140000000000 35.4440000000000 35.5900000000000 35.7150000000000 36.0690000000000 36.1730000000000 36.3400000000000 36.5270000000000 36.5900000000000 36.7150000000000 36.9640000000000 37.0270000000000 37.1730000000000 37.3190000000000 37.4640000000000 37.6100000000000 37.7770000000000 37.9230000000000 38.0680000000000 38.1520000000000 38.2980000000000 38.4230000000000 38.5480000000000 38.5480000000000 38.5680000000000 38.6100000000000 38.6520000000000 38.7140000000000 38.7770000000000 38.9230000000000 39.0900000000000 39.2360000000000 39.3810000000000 39.7140000000000 39.8390000000000 40.0060000000000 40.1310000000000 40.2560000000000 40.3810000000000 40.4640000000000 40.5270000000000 40.6100000000000 40.6930000000000 40.7550000000000 40.8800000000000 41.0260000000000 41.1300000000000 41.2350000000000 41.3810000000000 41.5260000000000 41.6510000000000 41.7560000000000 41.9220000000000 42.0890000000000 42.2140000000000 42.4850000000000 42.6520000000000 42.8600000000000 42.9650000000000 43.1520000000000 43.2560000000000 43.4020000000000 43.5060000000000 43.7140000000000 43.7560000000000 43.8390000000000 43.9010000000000 43.9850000000000 44.1100000000000 44.2140000000000 44.3380000000000 44.5470000000000 44.6720000000000 44.8380000000000 44.9630000000000 45.1300000000000 45.3380000000000 45.4420000000000 45.6500000000000 45.7540000000000 46.0870000000000 46.1910000000000 46.3580000000000 46.4620000000000 46.5460000000000 46.6290000000000 46.6710000000000 46.7540000000000 46.8170000000000 46.8790000000000 47.0460000000000 47.1080000000000 47.2130000000000 47.3590000000000 47.6710000000000 47.9000000000000 48.0660000000000 48.2540000000000 48.4210000000000 48.5460000000000 48.7120000000000 48.7950000000000 48.8160000000000 48.9210000000000 48.9830000000000 49.0250000000000 49.0670000000000 49.0870000000000 49.2120000000000 49.2960000000000 49.4210000000000 49.4840000000000 49.7120000000000 49.9410000000000 50.0450000000000 50.6070000000000 50.7320000000000 50.8370000000000 50.9200000000000 51.0040000000000 51.1290000000000 51.1910000000000 51.2960000000000 51.4210000000000 51.4830000000000 51.5250000000000 51.6080000000000 51.7130000000000 51.7540000000000 51.8170000000000 51.9210000000000 52.0040000000000 52.0660000000000 52.1910000000000 52.2950000000000 52.4620000000000 52.5450000000000 52.6910000000000 52.8160000000000 53.0650000000000 53.2320000000000 53.2950000000000 53.3980000000000 53.4400000000000 53.5240000000000 53.6280000000000 53.6490000000000 53.7530000000000 53.8570000000000 53.9200000000000 54.0660000000000 54.1490000000000 54.2730000000000 54.4190000000000 54.5230000000000 54.6280000000000 54.7320000000000 54.8160000000000 54.8990000000000 55.0240000000000 55.0860000000000 55.1490000000000 55.2320000000000 55.2950000000000 55.4200000000000 55.5030000000000 55.7110000000000 55.8150000000000 56.0650000000000 56.1910000000000 56.4200000000000 56.5030000000000 56.6070000000000 56.6910000000000 56.7530000000000 56.8570000000000 56.9830000000000 57.3160000000000 57.4610000000000 57.6280000000000 57.7730000000000 57.9610000000000 58.1270000000000 58.5020000000000 58.6690000000000 58.8150000000000 58.9190000000000 59.0650000000000 59.1690000000000 59.2520000000000 59.4190000000000 59.4190000000000 59.5230000000000 59.5440000000000 59.6280000000000 59.7530000000000 59.8160000000000 59.9410000000000 60.1490000000000 60.2950000000000 60.4610000000000 61.1270000000000 61.2530000000000 61.5020000000000 61.9390000000000 62.0850000000000 62.2100000000000 62.3770000000000 62.7100000000000 62.8980000000000 63.0440000000000 63.2940000000000 63.4820000000000 63.7110000000000 63.8980000000000 64.1060000000000 64.3150000000000 64.5020000000000 64.6900000000000 64.8770000000000 65.0850000000000 65.2100000000000 65.3150000000000 65.4400000000000 65.6270000000000 65.7310000000000 65.8560000000000 66.0230000000000 66.1270000000000 66.2510000000000 66.3560000000000 66.6470000000000 66.7510000000000 66.8760000000000 66.9380000000000 67.1890000000000 67.3140000000000 67.3970000000000 67.5220000000000 67.5640000000000 67.7310000000000 67.8560000000000 67.9810000000000 68.0650000000000 68.1480000000000 68.2730000000000 68.3980000000000 68.4810000000000 68.6060000000000 68.6680000000000 68.8140000000000 68.8970000000000 69.0220000000000 69.2090000000000 69.2920000000000 69.6460000000000 69.6670000000000 69.8340000000000 70.0840000000000 70.1890000000000 70.3140000000000 70.4810000000000 70.6050000000000 70.7510000000000 70.8760000000000 71.0430000000000 71.1470000000000 71.2720000000000 71.4390000000000 71.7100000000000 71.8770000000000 71.9810000000000 72.1470000000000 72.2720000000000 72.3550000000000 72.5010000000000 72.5430000000000 72.6470000000000 72.7520000000000 72.8140000000000 72.9610000000000 73.0440000000000 73.1690000000000 73.3140000000000 73.4810000000000 74.0430000000000 74.1890000000000 74.3980000000000 74.5220000000000 74.6050000000000 74.7100000000000 74.7300000000000 74.7720000000000 74.8130000000000 74.8330000000000 74.8960000000000 74.9370000000000 75.0210000000000 75.0620000000000 75.2080000000000 75.3540000000000 75.7080000000000 75.8750000000000 76.0630000000000 76.2300000000000 76.4380000000000 76.5430000000000 76.7090000000000 76.8760000000000 77.0010000000000 77.1260000000000 77.2720000000000 77.3770000000000 77.4800000000000 77.6050000000000 77.8550000000000 77.9600000000000 78.0640000000000 78.1060000000000 78.2100000000000 78.3970000000000 78.5220000000000 78.6270000000000 78.8550000000000 79.0430000000000 79.2300000000000 79.6470000000000 79.8760000000000 80.5220000000000 80.6260000000000 80.7930000000000 80.8550000000000 80.8970000000000 80.9180000000000 80.9390000000000 80.9810000000000 81.0430000000000 81.1270000000000 81.2730000000000 81.4600000000000 81.6270000000000 81.8350000000000 82.1260000000000 82.6260000000000 82.8760000000000 83.1050000000000 83.2720000000000 83.4390000000000 83.5850000000000 83.6890000000000 83.7310000000000 83.7100000000000 83.6890000000000 83.6890000000000 83.7100000000000 83.8350000000000 83.9180000000000 84.0850000000000 84.4600000000000 84.6890000000000 84.9180000000000 85.3970000000000 85.5220000000000 85.6260000000000 85.8560000000000 85.8550000000000 85.8560000000000 85.8760000000000 85.9380000000000 85.9390000000000 86.0430000000000 86.1470000000000 86.2510000000000 86.4180000000000 86.6470000000000 86.8550000000000 87.0850000000000 87.3340000000000 87.5630000000000 87.7720000000000 88.0630000000000 88.1890000000000 88.4390000000000 88.5430000000000 88.6480000000000 88.6480000000000 88.7100000000000 88.7730000000000 88.8770000000000 88.8980000000000 89.0010000000000 89.1050000000000 89.2930000000000 89.4180000000000 89.6470000000000 89.7930000000000 90.0010000000000 90.2100000000000 90.4180000000000 90.6060000000000 90.7100000000000 90.8770000000000 91.0640000000000 91.1680000000000 91.2720000000000 91.3560000000000 91.4180000000000 91.5220000000000 91.6470000000000 91.7310000000000 91.8350000000000 91.9180000000000 92.1060000000000 92.2310000000000 92.3760000000000 92.6060000000000 92.7930000000000 93.0010000000000 93.4180000000000 93.6470000000000 93.8970000000000 94.4180000000000 94.5840000000000 94.7300000000000 95.0220000000000 95.1890000000000 95.3140000000000 95.5220000000000 95.8140000000000 95.9180000000000 96.0640000000000 96.2300000000000 96.3130000000000 96.5010000000000 96.6260000000000 96.7720000000000 96.8560000000000 97.0230000000000 97.1680000000000 97.2720000000000 97.3970000000000 97.5430000000000 97.6680000000000 97.7520000000000 97.8770000000000 97.9600000000000 98.0650000000000 98.3360000000000 98.4190000000000 98.5230000000000 98.6070000000000 98.7320000000000 98.8150000000000 98.9190000000000 99.1060000000000 99.2520000000000 99.4190000000000 99.5860000000000 99.7940000000000 99.9190000000000 100.044000000000];
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
A1
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 whether the codes for SigmaI and BER is correct. I have an equation to code
To sigmaI, I is used, which is a 512*512 matrix. Also I need to calculate BER also. The equation is
The code that I wrote is,
clc;close all;clear all;
lambda = 532;
k = 2*pi/lambda;
z=[1.03700000000000 1.39100000000000 1.59800000000000 1.84800000000000 1.88900000000000 2.01400000000000 2.34800000000000 2.45100000000000 2.57600000000000 2.72200000000000 2.78500000000000 2.88900000000000 2.97200000000000 3.16000000000000 3.20200000000000 3.36900000000000 3.41100000000000 3.51500000000000 3.55700000000000 3.57700000000000 3.66100000000000 3.66100000000000 3.68100000000000 3.70200000000000 3.74400000000000 3.82800000000000 3.93200000000000 4.05700000000000 4.18200000000000 4.55600000000000 4.70200000000000 4.91000000000000 5.01500000000000 5.16100000000000 5.24400000000000 5.26500000000000 5.28600000000000 5.28600000000000 5.28600000000000 5.24400000000000 5.26400000000000 5.22300000000000 5.39000000000000 5.57700000000000 5.72200000000000 5.93100000000000 6.16000000000000 6.41000000000000 6.63800000000000 6.88800000000000 7.03400000000000 7.24200000000000 7.34700000000000 7.45100000000000 7.53400000000000 7.63900000000000 7.68000000000000 7.80500000000000 7.82600000000000 7.95100000000000 8.09700000000000 8.20100000000000 8.30600000000000 8.47200000000000 8.66000000000000 8.82600000000000 8.97200000000000 9.07700000000000 9.18100000000000 9.24300000000000 9.28400000000000 9.32600000000000 9.34700000000000 9.34700000000000 9.36800000000000 9.36800000000000 9.40900000000000 9.47200000000000 9.51400000000000 9.57600000000000 9.65900000000000 9.74200000000000 9.84600000000000 9.99200000000000 10.1790000000000 10.5130000000000 10.5760000000000 10.9710000000000 11.1380000000000 11.3260000000000 11.4090000000000 11.4710000000000 11.5130000000000 11.5550000000000 11.6170000000000 11.7000000000000 11.8250000000000 11.8870000000000 12.2830000000000 12.4910000000000 12.6370000000000 12.8040000000000 12.9490000000000 13.1150000000000 13.2610000000000 13.5540000000000 13.6790000000000 13.8240000000000 13.9080000000000 14.3040000000000 14.3870000000000 14.4910000000000 14.5740000000000 14.6370000000000 14.7620000000000 14.8450000000000 14.9490000000000 15.0320000000000 15.1370000000000 15.2820000000000 15.3650000000000 15.5320000000000 15.6160000000000 15.7410000000000 15.8870000000000 16.0530000000000 16.1570000000000 16.3650000000000 16.5940000000000 16.7400000000000 16.8650000000000 16.9280000000000 17.0530000000000 17.0950000000000 17.1780000000000 17.2200000000000 17.3030000000000 17.3440000000000 17.5530000000000 17.6980000000000 17.8020000000000 17.9900000000000 18.1360000000000 18.3650000000000 18.5740000000000 18.8030000000000 18.9900000000000 19.1980000000000 19.5100000000000 19.6560000000000 19.8430000000000 19.9690000000000 20.0940000000000 20.1760000000000 20.3220000000000 20.4680000000000 20.5930000000000 20.7590000000000 20.9050000000000 21.0510000000000 21.1970000000000 21.4260000000000 21.5920000000000 21.7170000000000 21.9050000000000 22.0300000000000 22.2180000000000 22.3430000000000 22.5510000000000 22.8420000000000 23.0920000000000 23.1960000000000 23.4250000000000 23.5920000000000 23.7170000000000 23.8630000000000 24.0500000000000 24.1960000000000 24.3210000000000 24.5910000000000 24.7370000000000 24.8620000000000 25.0490000000000 25.2580000000000 25.5490000000000 25.7160000000000 25.8830000000000 26.0910000000000 26.2370000000000 26.3200000000000 26.6960000000000 27.4040000000000 27.6120000000000 27.7790000000000 27.9870000000000 28.1540000000000 28.3620000000000 28.5280000000000 28.6950000000000 28.8830000000000 29.2370000000000 29.4450000000000 29.5490000000000 29.7990000000000 29.9650000000000 30.1320000000000 30.3190000000000 30.5070000000000 30.6950000000000 30.8200000000000 30.9860000000000 31.1320000000000 31.3200000000000 31.3820000000000 31.4870000000000 31.5910000000000 31.7580000000000 31.8610000000000 31.9870000000000 32.0700000000000 32.3610000000000 32.4860000000000 32.6320000000000 32.8810000000000 33.0060000000000 33.0480000000000 33.0690000000000 33.0900000000000 33.0900000000000 33.0690000000000 33.0270000000000 32.9240000000000 32.9030000000000 32.8610000000000 32.8820000000000 32.9030000000000 32.9660000000000 33.0490000000000 33.0910000000000 33.1740000000000 33.2570000000000 33.3200000000000 33.3820000000000 33.4660000000000 33.4440000000000 33.4230000000000 33.4020000000000 33.4230000000000 33.3810000000000 33.4020000000000 33.4020000000000 33.4020000000000 33.4020000000000 33.4020000000000 33.4440000000000 33.4640000000000 33.5270000000000 33.5270000000000 33.6110000000000 33.6520000000000 33.6730000000000 33.6930000000000 33.6740000000000 33.6740000000000 33.6320000000000 33.5280000000000 33.4650000000000 33.3820000000000 33.4030000000000 33.3610000000000 33.3400000000000 33.3200000000000 33.2570000000000 33.3410000000000 33.3820000000000 33.4240000000000 33.4440000000000 33.4650000000000 33.4440000000000 33.5060000000000 33.5060000000000 33.5480000000000 33.5480000000000 33.5480000000000 33.5690000000000 33.6100000000000 33.7350000000000 33.8390000000000 33.9220000000000 34.0270000000000 34.1310000000000 34.3180000000000 34.5480000000000 34.7350000000000 34.8810000000000 35.0480000000000 35.2140000000000 35.4440000000000 35.5900000000000 35.7150000000000 36.0690000000000 36.1730000000000 36.3400000000000 36.5270000000000 36.5900000000000 36.7150000000000 36.9640000000000 37.0270000000000 37.1730000000000 37.3190000000000 37.4640000000000 37.6100000000000 37.7770000000000 37.9230000000000 38.0680000000000 38.1520000000000 38.2980000000000 38.4230000000000 38.5480000000000 38.5480000000000 38.5680000000000 38.6100000000000 38.6520000000000 38.7140000000000 38.7770000000000 38.9230000000000 39.0900000000000 39.2360000000000 39.3810000000000 39.7140000000000 39.8390000000000 40.0060000000000 40.1310000000000 40.2560000000000 40.3810000000000 40.4640000000000 40.5270000000000 40.6100000000000 40.6930000000000 40.7550000000000 40.8800000000000 41.0260000000000 41.1300000000000 41.2350000000000 41.3810000000000 41.5260000000000 41.6510000000000 41.7560000000000 41.9220000000000 42.0890000000000 42.2140000000000 42.4850000000000 42.6520000000000 42.8600000000000 42.9650000000000 43.1520000000000 43.2560000000000 43.4020000000000 43.5060000000000 43.7140000000000 43.7560000000000 43.8390000000000 43.9010000000000 43.9850000000000 44.1100000000000 44.2140000000000 44.3380000000000 44.5470000000000 44.6720000000000 44.8380000000000 44.9630000000000 45.1300000000000 45.3380000000000 45.4420000000000 45.6500000000000 45.7540000000000 46.0870000000000 46.1910000000000 46.3580000000000 46.4620000000000 46.5460000000000 46.6290000000000 46.6710000000000 46.7540000000000 46.8170000000000 46.8790000000000 47.0460000000000 47.1080000000000 47.2130000000000 47.3590000000000 47.6710000000000 47.9000000000000 48.0660000000000 48.2540000000000 48.4210000000000 48.5460000000000 48.7120000000000 48.7950000000000 48.8160000000000 48.9210000000000 48.9830000000000 49.0250000000000 49.0670000000000 49.0870000000000 49.2120000000000 49.2960000000000 49.4210000000000 49.4840000000000 49.7120000000000 49.9410000000000 50.0450000000000 50.6070000000000 50.7320000000000 50.8370000000000 50.9200000000000 51.0040000000000 51.1290000000000 51.1910000000000 51.2960000000000 51.4210000000000 51.4830000000000 51.5250000000000 51.6080000000000 51.7130000000000 51.7540000000000 51.8170000000000 51.9210000000000 52.0040000000000 52.0660000000000 52.1910000000000 52.2950000000000 52.4620000000000 52.5450000000000 52.6910000000000 52.8160000000000 53.0650000000000 53.2320000000000 53.2950000000000 53.3980000000000 53.4400000000000 53.5240000000000 53.6280000000000 53.6490000000000 53.7530000000000 53.8570000000000 53.9200000000000 54.0660000000000 54.1490000000000 54.2730000000000 54.4190000000000 54.5230000000000 54.6280000000000 54.7320000000000 54.8160000000000 54.8990000000000 55.0240000000000 55.0860000000000 55.1490000000000 55.2320000000000 55.2950000000000 55.4200000000000 55.5030000000000 55.7110000000000 55.8150000000000 56.0650000000000 56.1910000000000 56.4200000000000 56.5030000000000 56.6070000000000 56.6910000000000 56.7530000000000 56.8570000000000 56.9830000000000 57.3160000000000 57.4610000000000 57.6280000000000 57.7730000000000 57.9610000000000 58.1270000000000 58.5020000000000 58.6690000000000 58.8150000000000 58.9190000000000 59.0650000000000 59.1690000000000 59.2520000000000 59.4190000000000 59.4190000000000 59.5230000000000 59.5440000000000 59.6280000000000 59.7530000000000 59.8160000000000 59.9410000000000 60.1490000000000 60.2950000000000 60.4610000000000 61.1270000000000 61.2530000000000 61.5020000000000 61.9390000000000 62.0850000000000 62.2100000000000 62.3770000000000 62.7100000000000 62.8980000000000 63.0440000000000 63.2940000000000 63.4820000000000 63.7110000000000 63.8980000000000 64.1060000000000 64.3150000000000 64.5020000000000 64.6900000000000 64.8770000000000 65.0850000000000 65.2100000000000 65.3150000000000 65.4400000000000 65.6270000000000 65.7310000000000 65.8560000000000 66.0230000000000 66.1270000000000 66.2510000000000 66.3560000000000 66.6470000000000 66.7510000000000 66.8760000000000 66.9380000000000 67.1890000000000 67.3140000000000 67.3970000000000 67.5220000000000 67.5640000000000 67.7310000000000 67.8560000000000 67.9810000000000 68.0650000000000 68.1480000000000 68.2730000000000 68.3980000000000 68.4810000000000 68.6060000000000 68.6680000000000 68.8140000000000 68.8970000000000 69.0220000000000 69.2090000000000 69.2920000000000 69.6460000000000 69.6670000000000 69.8340000000000 70.0840000000000 70.1890000000000 70.3140000000000 70.4810000000000 70.6050000000000 70.7510000000000 70.8760000000000 71.0430000000000 71.1470000000000 71.2720000000000 71.4390000000000 71.7100000000000 71.8770000000000 71.9810000000000 72.1470000000000 72.2720000000000 72.3550000000000 72.5010000000000 72.5430000000000 72.6470000000000 72.7520000000000 72.8140000000000 72.9610000000000 73.0440000000000 73.1690000000000 73.3140000000000 73.4810000000000 74.0430000000000 74.1890000000000 74.3980000000000 74.5220000000000 74.6050000000000 74.7100000000000 74.7300000000000 74.7720000000000 74.8130000000000 74.8330000000000 74.8960000000000 74.9370000000000 75.0210000000000 75.0620000000000 75.2080000000000 75.3540000000000 75.7080000000000 75.8750000000000 76.0630000000000 76.2300000000000 76.4380000000000 76.5430000000000 76.7090000000000 76.8760000000000 77.0010000000000 77.1260000000000 77.2720000000000 77.3770000000000 77.4800000000000 77.6050000000000 77.8550000000000 77.9600000000000 78.0640000000000 78.1060000000000 78.2100000000000 78.3970000000000 78.5220000000000 78.6270000000000 78.8550000000000 79.0430000000000 79.2300000000000 79.6470000000000 79.8760000000000 80.5220000000000 80.6260000000000 80.7930000000000 80.8550000000000 80.8970000000000 80.9180000000000 80.9390000000000 80.9810000000000 81.0430000000000 81.1270000000000 81.2730000000000 81.4600000000000 81.6270000000000 81.8350000000000 82.1260000000000 82.6260000000000 82.8760000000000 83.1050000000000 83.2720000000000 83.4390000000000 83.5850000000000 83.6890000000000 83.7310000000000 83.7100000000000 83.6890000000000 83.6890000000000 83.7100000000000 83.8350000000000 83.9180000000000 84.0850000000000 84.4600000000000 84.6890000000000 84.9180000000000 85.3970000000000 85.5220000000000 85.6260000000000 85.8560000000000 85.8550000000000 85.8560000000000 85.8760000000000 85.9380000000000 85.9390000000000 86.0430000000000 86.1470000000000 86.2510000000000 86.4180000000000 86.6470000000000 86.8550000000000 87.0850000000000 87.3340000000000 87.5630000000000 87.7720000000000 88.0630000000000 88.1890000000000 88.4390000000000 88.5430000000000 88.6480000000000 88.6480000000000 88.7100000000000 88.7730000000000 88.8770000000000 88.8980000000000 89.0010000000000 89.1050000000000 89.2930000000000 89.4180000000000 89.6470000000000 89.7930000000000 90.0010000000000 90.2100000000000 90.4180000000000 90.6060000000000 90.7100000000000 90.8770000000000 91.0640000000000 91.1680000000000 91.2720000000000 91.3560000000000 91.4180000000000 91.5220000000000 91.6470000000000 91.7310000000000 91.8350000000000 91.9180000000000 92.1060000000000 92.2310000000000 92.3760000000000 92.6060000000000 92.7930000000000 93.0010000000000 93.4180000000000 93.6470000000000 93.8970000000000 94.4180000000000 94.5840000000000 94.7300000000000 95.0220000000000 95.1890000000000 95.3140000000000 95.5220000000000 95.8140000000000 95.9180000000000 96.0640000000000 96.2300000000000 96.3130000000000 96.5010000000000 96.6260000000000 96.7720000000000 96.8560000000000 97.0230000000000 97.1680000000000 97.2720000000000 97.3970000000000 97.5430000000000 97.6680000000000 97.7520000000000 97.8770000000000 97.9600000000000 98.0650000000000 98.3360000000000 98.4190000000000 98.5230000000000 98.6070000000000 98.7320000000000 98.8150000000000 98.9190000000000 99.1060000000000 99.2520000000000 99.4190000000000 99.5860000000000 99.7940000000000 99.9190000000000 100.044000000000];
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
A1
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 whether the codes for SigmaI and BER is correct. equation MATLAB Answers — New Questions
Different LME outputs for “same” data
Me and my advisor were both working with the same dataset, but I had preemptively filtered mine so there were no table rows where the main variable of interest was NaN. We both ran the same LME (using the fitlme) function, but got slightly different results. Matlab’s write-up of this function, and our understanding of it, is that it censors out the missing data and indeed we saw that we had the same number of observations included in both our models despite my advisor’s table having more rows (that include the NaNs); this is as we expect. But then why were the model fit statistics and fixed effects coefficients slightly different? Most differences were very very small with the exception of one fixed effects coefficient that was drastically different.
The model would be something like this ‘outcome ~ 1 + A + B*C + (1 + A + B*C | subjectID)’ and the NaNs I preemtively filtered were part of the outcome variable where A, B, and C would have actually had data.
(I did re-create both of these results on my own computer over and over again with the only change being my own deletion of the NaN rows).Me and my advisor were both working with the same dataset, but I had preemptively filtered mine so there were no table rows where the main variable of interest was NaN. We both ran the same LME (using the fitlme) function, but got slightly different results. Matlab’s write-up of this function, and our understanding of it, is that it censors out the missing data and indeed we saw that we had the same number of observations included in both our models despite my advisor’s table having more rows (that include the NaNs); this is as we expect. But then why were the model fit statistics and fixed effects coefficients slightly different? Most differences were very very small with the exception of one fixed effects coefficient that was drastically different.
The model would be something like this ‘outcome ~ 1 + A + B*C + (1 + A + B*C | subjectID)’ and the NaNs I preemtively filtered were part of the outcome variable where A, B, and C would have actually had data.
(I did re-create both of these results on my own computer over and over again with the only change being my own deletion of the NaN rows). Me and my advisor were both working with the same dataset, but I had preemptively filtered mine so there were no table rows where the main variable of interest was NaN. We both ran the same LME (using the fitlme) function, but got slightly different results. Matlab’s write-up of this function, and our understanding of it, is that it censors out the missing data and indeed we saw that we had the same number of observations included in both our models despite my advisor’s table having more rows (that include the NaNs); this is as we expect. But then why were the model fit statistics and fixed effects coefficients slightly different? Most differences were very very small with the exception of one fixed effects coefficient that was drastically different.
The model would be something like this ‘outcome ~ 1 + A + B*C + (1 + A + B*C | subjectID)’ and the NaNs I preemtively filtered were part of the outcome variable where A, B, and C would have actually had data.
(I did re-create both of these results on my own computer over and over again with the only change being my own deletion of the NaN rows). fitlme, lme, statistics MATLAB Answers — New Questions
How plot a grid of rectangles on an overlaid circle?
How to plot a circle of radius R and an overlaid grid of rectangles (with each rectangle of dimensions LxW)?
Choice of dimensions are so that the rectangular grid is larger than the dimeter of the circle and the centre of the circle is on one of the rectangle corners within the grid. The circle fully sits within the rectangular grid.
Secondly, from the plot or otherwise can Matlab help count the full rectangles within the circle?How to plot a circle of radius R and an overlaid grid of rectangles (with each rectangle of dimensions LxW)?
Choice of dimensions are so that the rectangular grid is larger than the dimeter of the circle and the centre of the circle is on one of the rectangle corners within the grid. The circle fully sits within the rectangular grid.
Secondly, from the plot or otherwise can Matlab help count the full rectangles within the circle? How to plot a circle of radius R and an overlaid grid of rectangles (with each rectangle of dimensions LxW)?
Choice of dimensions are so that the rectangular grid is larger than the dimeter of the circle and the centre of the circle is on one of the rectangle corners within the grid. The circle fully sits within the rectangular grid.
Secondly, from the plot or otherwise can Matlab help count the full rectangles within the circle? geometry, plotting, mesh MATLAB Answers — New Questions