from TXT file to a matrix in matlab

1 次查看(过去 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