how to plot two-column text file of the energy spectra
2 次查看(过去 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!