Reading a number from text file

조회 수: 2 (최근 30일)
Mete Altay
Mete Altay 2019년 1월 17일
댓글: Mete Altay 2019년 1월 17일
I am trying to read a value from a f06 file which is a general text file contains numbers, strings.I have added the text file and underlined the value that ı want to read.Can anyone help with this? Below you can find my code but it doesnt work.
clc;
clear all;
fid = fopen('composite_lamina-density.f06','r');
frmat='MASS AXIS SYSTEM \n %s %d %f %f %f';
C = fscanf(fid,frmat);
C
fclose(fid);
  댓글 수: 2
Stephen23
Stephen23 2019년 1월 17일
편집: Stephen23 2019년 1월 17일
@Mete Altay: we cannot import text data from a screenshot, we cannot edit text in a screenshot, we cannot search text in a screenshot, we cannot use your screenshot in any meaningful way. If you want help with this then upload your text file as a text file.
Mete Altay
Mete Altay 2019년 1월 17일
I added a text file.Waiting for your answer...

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2019년 1월 17일
편집: Stephen23 2019년 1월 17일
>> str = fileread('MASS.txt');
>> tmp = regexp(str,'(?<=X\s+)\d+\.?\d*E[-+]\d+','match','once');
>> str2double(tmp)
ans = 3.959280000000000

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by