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.

1 vue (au cours des 30 derniers jours)
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

Réponse acceptée

KSSV
KSSV le 27 Jan 2022
Modifié(e) : KSSV le 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 commentaires
KSSV
KSSV le 27 Jan 2022
Hey there was a typo error in the code. Now I have edited it, Check the code now.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by