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 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

KSSV
KSSV am 27 Jan. 2022
Bearbeitet: KSSV am 27 Jan. 2022
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 Kommentare
KSSV
KSSV am 27 Jan. 2022
Hey there was a typo error in the code. Now I have edited it, Check the code now.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by