r*******y 发帖数: 1081 | 1 on matlab I can use meshgrid as below
[x, y] = meshgrid(1:3, 1:2) and I get
x =
1 2 3
1 2 3
y =
1 1 1
2 2 2
then I can use simple code below to
get all the pairs of choices of x and y:
record =[]
for j = 1 :3
record = [record; x(1, j) y(1, j); x(2, j) y(2, j)];
end
and get the record:
record =
1 1
1 2
2 1
2 2
3 1
3 2
How can I get this record on linux shell? I know seq on linux can generate
a sequence. But now there are two numbers in each line in the record. I
think
there may be some choice on linux shell to do this job.
Thanks for your reading and suggestion. | l*******G 发帖数: 1191 | 2 The following command (all in one line)
for i in $(seq 1 3) ; do for j in $(seq 1 2) ; do echo $i $j; done; done |
|