From array to a file

I have this array [0:0.1:10]; I want to write these numbers in a file with four columns for example: 0 0.1 0.2 0.3; 0.4 0.5 0.6 0.7; 0.8 0.9 1 1.1; ... Thanks

回答(1 个)

csvwrite('C:\somewhere\somefilename.txt', reshape(yourarray, 4, []).');
would be one way. Assuming that the number of elements in the array is a multiple of 4 of course.

2 个评论

Thanks Guillaume, In general the length of array is not multiple of 4....
In addition as a delimiter I want just a space between number not commas... Thank you

请先登录,再进行评论。

类别

在 帮助中心 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息

提问:

2017-10-17

评论:

2017-10-17

Community Treasure Hunt

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

Start Hunting!

Translated by