如何将每个循环中的数据存储到数组或表格中? [英] how to store the data from each loop into an array or table form?

查看:29
本文介绍了如何将每个循环中的数据存储到数组或表格中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

For[n = 1, n < 6, n = n + 1,
   For[m = 1, m < 6, m = m + 1, abc = doc[[n]];
   kk = doc[[m]];
   v =vector[abc, kk]; 
   vl = VectorLength[v]]]

我想将每个循环中的数据存储到数组或表格形式中.我该怎么做?

I want to store the data from each loop into an array or table form. How can I do that?

推荐答案

尝试使用 Table 而不是两个 For 循环.它返回结果列表的列表(基本上是一个矩阵)

Try using a Table instead of two For loops. It returns a list of lists of the results (a matrix basically)

Table[
 abc = doc[[n]];
 kk = doc[[m]];
 v = vector[abc, kk];
 vl = VectorLength[v], {n, 1, 5}, {m, 1, 5}]

这篇关于如何将每个循环中的数据存储到数组或表格中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆