1

I'm trying to read a number in scientific e notation from like 5 from a textfile of format

VEV: 1.500000e+15
Lambda: 9.364217e-107
mu: 1.451533e-38
M: 2.435300e+17
Length Scale Xi: 2.435724e+37
Force Scale Beta: 1.597305e+07
Force Scale Gamma: 2.570301e-45
Energy Density Scale Sigma: 1.185159e-46

specifically from line 7. I have the following code

Paramater_ID = fopen(Parameter_File_Path, 'rt');

C = textscan(Paramater_ID,'%f',1,'headerlines',6);

However this just returns a cell array of '[]' with no errors.

Any help will be much appreciated!

SamuraiMelon
  • 297
  • 3
  • 11
  • can you explain more please, you want to read just the value of this variable `Length Scale Xi(GeV^-1): 2.435724e+37` ? and your data is not uniform(every line contains different several kinds of formatting)?? – Bilal May 11 '20 at 21:02
  • I want to read the number, after the string of this line: Force Scale Gamma(GeV): 2.570301e-45, so then I want it to read in 2.570301e-45. If it also helps, all the numbers are .6 precision as well. – SamuraiMelon May 11 '20 at 21:09

1 Answers1

1

This code will give you the answer hopefully:

clc
clearvars
close all
format long
%----------------------------------
Parameter_File_Path = 'Parameter_File_Path';
Paramater_ID = fopen(Parameter_File_Path, 'rt');
C = textscan(Paramater_ID,'%s %s %s %f',1,'headerlines',6);
C(4)
fclose(Paramater_ID);
%----------------------------------
Bilal
  • 3,191
  • 4
  • 21
  • 49