How to take comlex number from edit text into listbox in Matlab?

1 回表示 (過去 30 日間)
Enes Karaosman
Enes Karaosman 2016 年 3 月 27 日
編集済み: Enes Karaosman 2016 年 3 月 27 日
i want to take the double number from the editText into an array(when user pressed Add button) displaying in listbox, then do some calculations
For ex:
  1. User enters in editText : 2 + 2i -> Add
  2. 0.3 -> Add
i couldnt store entries in an array..

回答 (1 件)

Joseph Cheng
Joseph Cheng 2016 年 3 月 27 日
編集済み: Joseph Cheng 2016 年 3 月 27 日
Take a look at the function regexp() http://www.mathworks.com/help/matlab/ref/regexp.html and with the input like the example below you get both the real and complex return
txt = '1+2i'
regexp(txt,'\w*i*\w*','match')
however read a bit more about regexp as depending on how people type it in you get different answers.

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by