how to plot two-column text file of the energy spectra
2 views (last 30 days)
Show older comments
mohd akmal masud
on 26 May 2023
Commented: mohd akmal masud
on 30 Jun 2023
Dear all,
as attached is a two-column text file of the energy spectra. anyone can help me to plot it?
4 Comments
Star Strider
on 27 May 2023
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), '.-')
.
Accepted Answer
dpb
on 28 May 2023
Edited: dpb
on 29 May 2023
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...
More Answers (1)
dpb
on 30 Jun 2023
data=readmatrix('point1.prn.xlsx');
whos data
plot(data(:,1),data(:,2))
Seems easy enough...
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!