how to plot two-column text file of the energy spectra
조회 수: 5 (최근 30일)
이전 댓글 표시
Dear all,
as attached is a two-column text file of the energy spectra. anyone can help me to plot it?
댓글 수: 4
Star Strider
2023년 5월 27일
At least one is a binary file. What is the format? What are we supposed to do with it?
Uzip1 = unzip('point1.zip')
Uzip2 = unzip('point.zip')
Uzip3 = unzip('point1 (2).zip')
type(Uzip1{1})
fidi1 = fopen(Uzip1{1})
A = fread(fidi1, [128 2], 'double')
figure
plot(A(:,1), A(:,2), '.-')
.
채택된 답변
dpb
2023년 5월 28일
편집: dpb
2023년 5월 29일
uzip = unzip('point.zip')
spec=readmatrix('point/point1.prn','filetype','text');
whos spec
figure
plot(spec, 'x-')
Doesn't look too interesting, what's the data itself look like????
spec
Almost everything in what supposed to be a text file of numbers wasn't able to be read as numbers...what's the content of the file itself....?
type point/point1.prn
Well, that's a text file, indeed, but whatever you did before zipping up the results did NOT result in the results described as "which now produces a new file point1.prn. This is a two-column text file of the energy spectra...".
You'll need to go through the steps as described; eventually somehow you'll manage to get a text file that does actually contain the data itself I presume, but it's simply too inconvenient of a form here to keep poking at when don't have a klew what all the stuff referred to is or where it came from or...
As the above shows, when you get to that desired .prn file, it will take almost nothing to read and plot it, but getting to that point is NOT a MATLAB problem; that's all tied up in whatever system it is that produced the data files and its toolset.
ADDENDUM:
Maybe the data follow the header??? This platform limits the amount of output shown so have to work around that to see anything -- that's why it so inconvenient to not have the text file itself attached...anyways, let's try
spec=readlines('point/point1.prn'); % read as text
whos spec
spec(19)
Well, that's not it, either -- readmatrix did the best it could; all that file contains is the descriptive data and the empty last record...
추가 답변 (1개)
dpb
2023년 6월 30일
data=readmatrix('point1.prn.xlsx');
whos data
plot(data(:,1),data(:,2))
Seems easy enough...
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!