Symbolic value assignment in GUIDE

1 回表示 (過去 30 日間)
Muhendisleksi
Muhendisleksi 2017 年 12 月 20 日
コメント済み: Muhendisleksi 2017 年 12 月 22 日
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
F=get(handles.edit1,'String');
D=get(handles.edit3,'String');
f = sym(F);
D = symvar(D);
turev =diff(f,D);
set(handles.text2,'String',turev) % there is an error here

採用された回答

Geoff Hayes
Geoff Hayes 2017 年 12 月 20 日
Muhendisleksi - try using char to convert the symbolic expression to a string that you can then set in the text control. For example,
...
turev =diff(f,D);
set(handles.text2,'String',char(turev)) % there is an error here
Unfortunately, I don't have the Symbolic Toolbox so I can't confirm if the above will work.
  2 件のコメント
Walter Roberson
Walter Roberson 2017 年 12 月 20 日
Yes, that should work.
If you have a symbolic array, then if you char() it then you will get text that begins with 'matrix(' which you probably do not want. So for that, use
arrayfun(@char, SymbolicVariableNameHere, 'uniform', 0)
to get a cell array of character vectors with the contents. You would then have to decide how you wanted to present that array as text.
Muhendisleksi
Muhendisleksi 2017 年 12 月 22 日
thanks Geoff Hayes

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by