Cell to string

3 Ansichten (letzte 30 Tage)
Fiboehh
Fiboehh am 28 Mai 2011
Hellow, i'm reading in data from an ascii file. And i get it with
Inputpara = textscan(fid,'%s',14,'delimiter','\n'); % Read strings delimited
Meapara = Inputpara{1};
Mvalues = cellfun(@(x)sscanf(x,'%f'),Meapara(5:end))
And now i can get the number out of Mvalues! But there are also string in it i want to use. Meapara exist of several strings like 'Stringvalue // value of string' Now i want to extract everything before the // . So i want a STRING! I tried everything but always error... that it is a cell and not a string... Please help me :)
  2 Kommentare
Oleg Komarov
Oleg Komarov am 28 Mai 2011
Please post some lines of your input file and the desired output you want to attain.
Jan
Jan am 28 Mai 2011
If you show, what you have done and which error message appeared, we could suggest an improvement.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 29 Mai 2011
strings = regexp(Meapara,'^(.*?)//', 'tokens');
strings will now be a cell array of the parts before the // -- including any spacing (since you did say you want to extract everything before the //).

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by