How can i store the values for each of the 10 iterations of N. i want to store each and every value of the loop.

2 次查看(过去 30 天)
L=2;
element=10;
lambda=1.3;
l=lambda/2;
X3=[-7.655; 6.534];
Y3=[1.393;-7.03];
p=0;
%% loop for the elements of irs
for N=100:100:1000
nn=N;
x_e = zeros(element,N/10,L,N);
y_e = zeros(element,N/10,L,N);
for i=1:L
for j=1:element
for k=1:(nn)/(10)
x3(j,k,i) = X3(i,1) + p; % X coordinate of an element of IRS for plotting
y3(j,k,i) = Y3(i,1); % Y coordinate of an element of IRS for plotting
p=k*l;
x_e(j,k,i,nn) = x3(j,k,i);
y_e(j,k,i,nn)= y3(j,k,i);
end
p=0;
Y3(i,1) = Y3(i,1) + l;
end
% plot(x3,y3,'bo','HandleVisibility','off')
end
end

采纳的回答

KSSV
KSSV 2022-1-27
编辑:KSSV 2022-1-27
Note: You have to initialize the arrays x3, y3
L=2;
element=10;
lambda=1.3;
l=lambda/2;
X3=[-7.655; 6.534];
Y3=[1.393;-7.03];
p=0;
%% loop for the elements of irs
N=100:100:1000 ;
NN = length(N) ;
x_e = zeros(element,NN/10,L,NN);
y_e = zeros(element,NN/10,L,NN);
for n = 1:length(N)
nn=N(n);
for i=1:L
for j=1:element
for k=1:(nn)/(10)
x3(j,k,i) = X3(i,1) + p; % X coordinate of an element of IRS for plotting
y3(j,k,i) = Y3(i,1); % Y coordinate of an element of IRS for plotting
p=k*l;
x_e(j,k,i,n) = x3(j,k,i); % <-- edited here
y_e(j,k,i,n)= y3(j,k,i); % <-- edited here
end
p=0;
Y3(i,1) = Y3(i,1) + l;
end
% plot(x3,y3,'bo','HandleVisibility','off')
end
end
  7 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by