Effacer les filtres
Effacer les filtres

from TXT file to a matrix in matlab

1 vue (au cours des 30 derniers jours)
Alexandru Stan
Alexandru Stan le 30 Mai 2013
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?

Réponse acceptée

Alexandru Stan
Alexandru Stan le 30 Mai 2013
Thanks, I used Import Data menu but this is better...

Plus de réponses (1)

Eugene
Eugene le 30 Mai 2013
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
>>

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by