我想读Matlab.The文本/ CSV文件,文件看起来像:
VolumeDisplacement,9783.47
CenterOfBuoyancy,-0.732585,3.16072e-14,-3.09939
WettedSurfaceArea,2709.66
WaterlineLength,102.156
MaximumWaterlineBeam,20.76
WaterPlaneArea,1774.4
CenterOfFloatation,-6.32016,1.00108e-11,0
该文件使用产生vbscript
中的Rhinoceros
。 我使用帮助文件中给出的标准方法,但遇到一个奇怪的问题。
filename = 'RhinoResult.txt';
fid = fopen(filename);
line = fgetl(fid);
tline = textscan(line,'%s%d','Delimiter',',');
VolumeDisplacement=tline{2};
但是,并不如预期我的结果。 该tline
与每个字符之间的空间存储所述字符串。 此外,还有两个未知字符(ÿþ)
开头。
tline{1} = 'ÿþV o l u m e D i s p l a c e m e n t '
VBScript的用于创建文本文件看起来是这样的:
Sub writeResult(arrResults, filePath, fileName)
Dim objFSO,objFile
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(filePath & fileName, _
ForWriting, True)
objFile.Write "VolumeDisplacement," & arrResults(0)
objFile.Writeline
objFile.Write "CenterOfBuoyancy," & arrResults(1)
objFile.Writeline
objFile.Write "WettedSurfaceArea," & arrResults(2)
objFile.Writeline
objFile.Write "WaterlineLength," & arrResults(3)
objFile.Writeline
objFile.Write "MaximumWaterlineBeam," & arrResults(4)
objFile.Writeline
objFile.Write "WaterPlaneArea," & arrResults(5)
objFile.Writeline
objFile.Write "CenterOfFloatation," & arrResults(6)
objFile.Writeline
objFile.Close
End Sub
有人可以帮我弄这个吗?
谢谢,Amitava