简体   繁体   中英

Matrix generation with octave in a loop

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?

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

save(int2str(N), "A")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM