필터 지우기
필터 지우기

How do I write two strings to the same line using dlmwrite?

조회 수: 3 (최근 30일)
Poul Reitzel
Poul Reitzel 2012년 7월 25일
Dear Matlab Community
I am having trouble using dlmwrite (and maybe dlmwrite is not the right tool here!) to write a variable number of strings to one line in .dat file.
I think the issue is best illustrated by an example.
I am writing data processed in Matlab to a text file (.dat format). In the first two columns I always write a number and a string, e.g.
no. SN-curve
107 'Curve-D'
In the columns following these first two, i write a variable number of numbers (directions, sorted in a vector), e.g.
no. SN-curve Direc Direc Direc Direc Direc
107 'Curve-D' 0.00 30.0 60.0 90.0 120.0
The final column of the line must contain a number (a time to failure, i.e. lifetime of a component), that is always placed on the same position, i.e. the number of blanks between '120' and the final number is variable and depends on the number directions, e.g.
no. SN-curve Direc Direc Direc Direc Direc LIFE
107 'Curve-D' 0.00 30.0 60.0 90.0 120.0 75 108 'Curve-D' 0.00 30.0 60.0 90.0 92
So for no. 108 only four directions exist, but the lifetime must be aligned.
I hope that I made the issue clear :-)
Thanks in advance, Poul
  댓글 수: 2
Poul Reitzel
Poul Reitzel 2012년 7월 25일
no. SN-curve Direc Direc Direc Direc Direc LIFE
107 'Curve-D' 0.00 30.0 60.0 90.0 120.0 75
108 'Curve-D' 0.00 30.0 60.0 90.0 92
I think the format was lost somewhere, hopefully this looks better...
Poul Reitzel
Poul Reitzel 2012년 7월 25일
Problem solved by building vector in a loop and writing the whole thing in one go.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by