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
KSSV
KSSV 2022년 1월 27일
Hey there was a typo error in the code. Now I have edited it, Check the code now.

댓글을 달려면 로그인하십시오.

추가 답변 (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