I have a *.m file which can read data in *.3ddose file (this is output data file from some simulation) and displays in the "Command Window" page of Matlab. Is there any way to write this displayed data into other text file?

1 Ansicht (letzte 30 Tage)
function m = ReadEppOutput(file) % open the file f = fopen(file, 'rb'); % read two integers which give the size of the image size = fread(f, 2, 'int'); % initialize the output matrix m = zeros(size(1), size(2)); % read the rows into the matrix for x = 1:size(1) m(x,:) = fread(f, size(2), 'single'); end
end
  1 Kommentar
Taindra Neupane
Taindra Neupane am 28 Nov. 2017
I have the similar question like i have .3ddose file as an output of simulation and i want to extract that file and display either in excel,or txt ot data file for dose analysis. Help would be much appreciated. Thank you. Tain

Melden Sie sich an, um zu kommentieren.

Antworten (2)

dpb
dpb am 9 Jan. 2014
function m = ReadEppOutput(file)
f = fopen(file, 'rb');
size = fread(f, 2, 'int');
Do NOT use size as a variable--that aliases the builtin Matlab function of the same name which is far too commonly used to get into such bad habits. Use something else for the variable here -- siz or sz or anything but size.
m = zeros(size(1), size(2));
% read the rows into the matrix
for x = 1:size(1)
m(x,:) = fread(f, size(2), 'single');
end
Why read the array row by row? Just read the array in one swell foop...
m=fread(f,[sz(2),inf],'single')';
f=fclose(f); % close the input file
To write it as a formatted file simply open a new file for writing and use fprintf() with appropriate formatting or one of the other higher-level i/o functions to write a csv file or however desired.
end

Ka Mirul
Ka Mirul am 13 Mai 2018
Hi, I think that at the first step you have to read the data to matlab variable first. I've write matlab code to read specific line of .3ddose data. You can read the tutorial here and download the code here .

Kategorien

Mehr zu Data Import and Export finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by