Save matlab output in textfile

2 次查看(过去 30 天)
I have two vectors in matlab with n-entries, let us call them x and y.
Now I want to create a textfile that has the following structure: You have two columns(one for the x values and one for the y-values) and then I want to get:
x(1) y(1)
x(2) y(2)
x(3) y(3)
and so on.
does anybody here know how this can be done?

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-8-23
编辑:Azzi Abdelmalek 2013-8-23
x=[1;2;3];
y=[10;20;30];
v=[x y]
dlmwrite('yourfile.txt',v,'delimiter',' ')
%or
dlmwrite('yourfile.txt',v,'delimiter','\t')

更多回答(2 个)

ES
ES 2013-8-23
Easier way is to use diary function.
diary on
Print everything on the command window using disp, and let diary take care of it.
and then switch off diary.

Nabin Bera
Nabin Bera 2016-6-1
i cant write my output data into a .txt file in matlab 2015a.

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by