how to insert fprintf value into GUI edit text box?

19 ビュー (過去 30 日間)
Phoebe
Phoebe 2021 年 4 月 18 日
コメント済み: Phoebe 2021 年 4 月 23 日
Hi there! I'm having issues on inserting my fprintf value into the GUI's edit text box...I think the error is at where I marked below but I can't seem to solve it. If you try to remove those two lines of code and just leave there as "fprintf('%s', morse{index});" , you will see my desire output at the command window...
In this case, you will see something similar as mentioned above but the difference is there'll be a random number showing in the GUI's edit text box...can someone help ? thanks!
morseoutput=fprintf('%s', morse{index}); %(I think here's the error)
set(handles.morsecode_output,'string',morseoutput) ;
  1 件のコメント
Stephen23
Stephen23 2021 年 4 月 19 日
"...there'll be a random number showing in the GUI's edit text box"
Not random: the fprintf documentation states that it returns the number of bytes printed to the command window or file.

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2021 年 4 月 18 日
編集済み: Stephen23 2021 年 4 月 18 日
You need to use sprintf, not fprintf:
  • sprintf creates a character vector/string (this is what you need).
  • fprintf prints directly to a file or the command window.
  24 件のコメント
Stephen23
Stephen23 2021 年 4 月 23 日
編集済み: Stephen23 2021 年 4 月 23 日
"like this"
No. As Walter Roberson pointed out, by using ISMEMBER you have already compared the content of those two variables, so you do not really need to compare them again. You can simply use the outputs from ISMEMBER together with ALL, ANY, and NOT as required. Start by looking at the inputs and outputs of these:
all(X)
any(X)
Look at your data, read the documentation, experiment!
Phoebe
Phoebe 2021 年 4 月 23 日
I finally got it!!! thanks again !!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by