GUI for basic operations in Boolean algebra

5 ビュー (過去 30 日間)
Virginia Radulescu
Virginia Radulescu 2019 年 11 月 9 日
コメント済み: Virginia Radulescu 2019 年 11 月 27 日
Hello,
I've tried to do a GUI for basic operations in Boolean algebra but it seems that I do something wrong when I do the type conversion.
The structure is simple, meaning that I have 2 editable controls for the data IN, a popup for the operations( NOT, OR, AND, XOR), a push button for result and a text control for displaying the result.
The function that makes the conversions is:
function pushResult_Callback(hObject, eventdata, handles)
firstInput = evalin('base','firstInput');
secondInput = evalin('base','secondInput');
operation = evalin('base','operation');
if (operation == 1)
% Operation1 --- NOT------------------
ans1=dec2bin(firstInput);
answer=bin2dec(~ans1);
set(handles.textResult_print,'String',answer);
.............................................................
The error that I'm getting is:
Error using bin2dec (line 36)
Input must be a character vector.
I don’t understand where do I ‘wrong.
Can anyone help me?
Thank you so much!
Virginia
  3 件のコメント
Adam
Adam 2019 年 11 月 12 日
Use breakpoints. When you use something like evalin it's anyone's guess what is going to be magically parachuted into your function's workspace. If you have editable controls for the data in why are you trying to access them from the base workspace rather than simply from those controls?
Virginia Radulescu
Virginia Radulescu 2019 年 11 月 27 日
Thank you! I will do so.

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

採用された回答

David Fink
David Fink 2019 年 11 月 27 日
編集済み: David Fink 2019 年 11 月 27 日
Like Adam mentioned, you can set breakpoints to run your code one line at a time in order to find the problem.
Alternatively, using dbstop via the command below, then running your code will pause right at the line that's throwing the error, and you can look at variables to see what values are unexpected.
>> dbstop if error
  1 件のコメント
Virginia Radulescu
Virginia Radulescu 2019 年 11 月 27 日
Thank you! I will do so.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by