Hey people, I am pretty new to matlab programming and I am trying to make an app for my masters thesis. Everything works except one thing, I am trying to read one word from a txt file and push in into the textarea value in appdesigner after a button is pushed. If I read the value of strp, it tells the word and its a string but for some reason it just wont appear in the TextArea :(
Could You help me out, thanks!
fileID = fopen('Prediction.txt');
app.predi = textscan(fileID,'%c');
fclose(fileID);
x = app.predi{1,1};
app.strp = convertCharsToStrings(x);
app.PredikcianruTextArea.Value = app.strp;

2 件のコメント

Kevin Chng
Kevin Chng 2019 年 2 月 27 日
attach your prediction.txt here. It will help if anyone is willing to try out.
Imrich K
Imrich K 2019 年 2 月 27 日
Hey, it is just a text file which contains only one word (the genre of the music the neural network recognizes) - so lets say it contains the word Blues.

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

 採用された回答

Jesus Sanchez
Jesus Sanchez 2019 年 2 月 27 日
編集済み: Jesus Sanchez 2019 年 2 月 28 日

1 投票

Did you try to use a char instead of string to show the results in textarea?
app.PredikcianruTextArea.Value = char(app.strp);
This might work. I am not really sure if textarea works with strings or chars, but I would say it is the latter.
PS: I did an app with a textarea and I used it as a means to give feedback regarding the application processes. If I remember correctly, I transformed the strings in chars before assigning them to TextArea.Value. Tomorrow I will look for the code and put it here :)
EDIT: This is the code. Note that the message is defined as char. The circshift is to shift the message to the top position of the textarea
feedback{end+1,1} = 'Connected to PNA';
feedback = circshift(feedback,1);
app.Log.Value = feedback;

4 件のコメント

Imrich K
Imrich K 2019 年 2 月 28 日
Hey, thanks for the suggestion. Now matlab does not give me errors and if I make the app write out the value of that variable it shows the genre e.g.: 'Classic' which is correct but the dang text area will not update itself to show it. If I put the same code in the StartupFcn, then it shows the value in the text area but as soon as I put it on the button, runs the script and then it wont show.
Jesus Sanchez
Jesus Sanchez 2019 年 3 月 1 日
Did you try to do
app.PredikcianruTextArea.Value = char(app.strp);
?
Imrich K
Imrich K 2019 年 3 月 2 日
Well, I did fix the issue it was caused by my dumb mistake. I did save the whole workspace instead of just saving the trained neural network (what I wanted to do) so the variable with the genre name was messed up. Now I fixed it by saving only the neural network and voila the TextArea shows the title of the recognized genre. But I also use your solution so will mark Your answer as the solution. Thanks for the tip!
Jesus Sanchez
Jesus Sanchez 2019 年 3 月 4 日
No problems! Congratulations in finding the error and good luck with your master thesis!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Develop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by