How can I fill in a matrix with the data of a multiline edittext box?

1 Ansicht (letzte 30 Tage)
Hello, I have a gui with a multiline edittext box and I want for example to write on three lines 9 numbers (3 numbers on each line) and to create a 3x3 matrix. How can I do that? I know that an edittext box get strings but how can my program count the written lines of my edittext, and then create a matrix with the transformed strings to numbers?
kind regards!

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 19 Nov. 2013
get(EditBoxHandle, 'String') is going to return a cell array of strings. length() of the cell array will tell you how many lines there are.
You will need to convert the strings to numbers. See sscanf()
  1 Kommentar
sadel
sadel am 20 Nov. 2013
Thank you for your answer, instead of sscanf() I used the str2num(). The results were a little bit better.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Word games 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