필터 지우기
필터 지우기

from TXT file to a matrix in matlab

조회 수: 1 (최근 30일)
Alexandru Stan
Alexandru Stan 2013년 5월 30일
Hi guys,
I have a text file with manny lines like this:
At (18.0,6.1) BX = -0.0242048317383725
At (18.0,6.1) BY = -0.186458932104758
At (18.0,6.3) BX = -0.0274870529222169
At (18.0,6.3) BY = -0.226398264696909
At (18.0,6.5) BX = -0.0307692741060612
At (18.0,6.5) BY = -0.266337597289061
I want to make two matrices (one with Bx and other with By), each one with three columns X Y Bx and X Y By. Can someone help me?

채택된 답변

Alexandru Stan
Alexandru Stan 2013년 5월 30일
Thanks, I used Import Data menu but this is better...

추가 답변 (1개)

Eugene
Eugene 2013년 5월 30일
Try this
>> [x y dir B] = textread('tt.txt','At (%f,%f) B%c = %f');
>> ax = [x(dir=='X') y(dir=='X') B(dir=='X')]
ax =
18.0000 6.1000 -0.0242
18.0000 6.3000 -0.0275
18.0000 6.5000 -0.0308
>> ay = [x(dir=='Y') y(dir=='Y') B(dir=='Y')]
ay =
18.0000 6.1000 -0.1865
18.0000 6.3000 -0.2264
18.0000 6.5000 -0.2663
>>

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by