循环中八度的矩阵生成

发布于 2024-12-29 20:10:19 字数 280 浏览 2 评论 0原文

你好,我想在 GNU-Octave 中为不同的 N 生成一些大小为 Nx3 的随机矩阵。我想将每个矩阵保存到不同的文件中。

下面的脚本几乎完成了这项工作,但奇怪的是它只生成名为 int2str(N) 的文件;它不断覆盖上一次迭代生成的文件。

for i=1:10
  N=(2**i)
  A=rand(N,3);
  save int2str(N) A
end

该脚本将 int2str(N) 本身解释为字符串。我该如何避免这种行为?

Hi I want to generate some random matrices of size Nx3 for varying N, in GNU-Octave. I want to save each of these matrices to a different file.

The script below almost does the job, but strangely it produces only file with the name int2str(N) ; it keeps overwriting the files produced at the previous iteration.

for i=1:10
  N=(2**i)
  A=rand(N,3);
  save int2str(N) A
end

The script is interpreting int2str(N) itself as a string. How do I avoid this behaviour?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

欢烬 2025-01-05 20:10:19

您可以使用函数形式调用 save

save(int2str(N), "A")

You can invoke save with the function form:

save(int2str(N), "A")

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文