Looping with arrays of two different lengths

1 次查看(过去 30 天)
My code is written as follows, Now here as we can see that a matrix A is generated of size 34x2 double which shows combination of travel between nodes(represented by n). t shows travel times between these nodes, therefore t also has 34 rows and its size is 34x1 double. now e and l correspond to number of nodes(n) therefor their size is 8x1 each respectively. I want to use the formula: e+t> l in one/many loops and want to make that index of A=[0;0] wherein this forua is true. in this formula t represents travel times between nodes and e and l are variable assosciated with n. the code is below for better understanding.
T_up = 1000;
n = 3;
A = [];
A = [A; 0, 2*n+1];
for i = 1:n
A = [A; 0, i];
end
for i = 1:2*n
for j = 1:2*n
if i ~=j && i ~= n+j
A = [A; i, j];
end
end
end
for i = n+1:2*n
A = [A; i, 2*n+1];
end
t = randi(15, length(A)-1, 1);
t=[0;t]
e = randi(150, n, 1);
l = [T_up; e + max(t(:)); e + 2*max(t(:)) + 25; T_up];
dlmwrite('l.txt', l);
e = [0; e; e; 0];
dlmwrite('e.txt', e);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by