how to plot two-column text file of the energy spectra
1 回表示 (過去 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...
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!