there is an error in describing the loop, please help me to resolve this one.
Show older comments
clear
x = linspace (-1,1,256);
y = linspace (-1,1,256);
[X,Y] = meshgrid(x,y);
r = sqrt(X.^2 + Y.^2);
z= 0;
w = 100;
E0 = 1;
O = rand(256,256);
E = E0*exp(-1i*(O));
A = (abs(E)).^2 ;
x=linspace(-1,1,256);
[X,Y]=meshgrid(x,x);
r=sqrt(X.^2+Y.^2);
R= 0.06;
t = 0.5;
l= 0:36:360;
M = cell(1,length(l));
for i = 1:length(l)
h= t*cosd(l(i));k= t*sind(l(i));
p=sqrt((X-h).^2+(Y-k).^2);
M{i}=(p<R);
end
M = M{1}+M{2}+M{3}+M{4}+M{5}+M{6}+M{7}+M{8}+M{9}+M{10};
Io=1.0;
Y=linspace(1,-1,256); Z=Y ;
A(1:length(Y),1:length(Z))=0;
for i=1:length(Y)
for j=1:length(Z)
q=(Y(i).^2+Z(j).^2).^0.5;
w = 0.3;
A(i,j)=Io.*exp(-((q.^2)./w^2));
end
end
G0 = 15;
I = 1;
E = E0*exp(-1i*(O));
for i = 1:100
G(i) = G0/(1+ (abs(E(i)))^2/I);
E(i+1) = M *(ifft(A*(fft(G* E(i)))));
end
imagesc(E)
3 Comments
Karim
on 30 Aug 2022
M*(ifft(A*(fft(G* E(i)))))
is a matrix of size 256x256
you are trying to store this into E( i+1 ) which is a scalar (i.e. a 1x1) location.
as a result you get an error which indicates that the left side (E(i+1)) doesn't have the same size as the right side (a 256x256 matrix)
Rik
on 30 Aug 2022
So the question is: what do you want to do?
Answering that question is very hard because you chose non-descriptive variable names and didn't write any comments. How do you expect anyone to understand what is going on in your code? Remember that you in three months time are a different person from current you. How is future you suposed to understand what you did and extend functionality or fix a bug?
SAHIL SAHOO
on 30 Aug 2022
Accepted Answer
More Answers (0)
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
