フィルターのクリア

Creating Library with App Designer

1 回表示 (過去 30 日間)
Esin Derin
Esin Derin 2019 年 12 月 22 日
コメント済み: Adam Danz 2019 年 12 月 28 日
value = app.ISBNEditField.Value;
ISBN=app.ISBNEditField.Value;
BOOKS=app.BOOKSListBox.Value;
GetBook=app.GetBookButton;
Information=app.InformationTextArea;
GetBook=[1234 1235 1236 1237];
Books=input('Anna Karenina,Les Miserables,War and Peace,Of Mice and Man','s');
function output=Library
if a == 1234
Information = 'Anna Karena';
elseif a == 1235
Information = 'Les Miserables';
elseif a == 1236
Information = 'War and Peace';
elseif a == 1237
Information = 'Of Mice and Men';
else
Information = 'not available';
end
app.InformationTextAreaLabel.Text = 'not available right now';
for i = 1 : length(app.BOOKSlist.Items)
if ISBN == app.BOOKSlist.Items(i)
app.InformationTextAreaLabel.Text = string(i);
break;
end
end
end
for app.GetBookButton=1234
app.InformationTextArea.Author=='Tolstoy';
app.InformationTextArea.Pages=='1000';
if app.GetBookButton==1235
app.InformationTextArea.Author=='Hugo';
app.InformationTextArea.Pages=='416';
for app.GetBookButton==1236
app.InformationTextArea.Author=='Tolstoy';
app.InformationTextArea.Pages='516';
for app.GetBookButton=1237
app.InformationTextArea.Author=='John Steinbeck';
app.InformationTextArea.Pages=='187';
end
end
It keeps giving me this error:
Error using Library
Error: File: Library.mlapp Line: 53 Column: 16
Unexpected MATLAB operator.
  3 件のコメント
Esin Derin
Esin Derin 2019 年 12 月 24 日
app.InformationTextArea.Author=='Tolstoy';
app.InformationTextArea.Pages=='1000';
With equal signs.
Esin Derin
Esin Derin 2019 年 12 月 24 日
Defined a function with two variables but this isn't working either.No error,just not working.
function output = my_output(x,y)
ISBN=app.ISBNEditField.Value;
BOOKS=app.BOOKSListBox.Value;
% it affect app getbookbutton to getbookbutton
GetBook=app.GetBookButton;
Information=app.InformationTextAreaLabel.Text;
GetBook=[1234, 1235 ,1236, 1237];
% this function output the information of book
% count number of enter books
for i = 1 : length(app.BOOKSlist.Items)
if ISBN == app.BOOKSlist.Items(i)
app.InformationTextAreaLabel.Text = string(i);
break;
end
if app.GetBookButton==1234
app.InformationTextArea.Author='Tolstoy';
app.InformationTextArea.Pages='1000';
output(app.InformationTextArea.Author,app.InformationTextArea.Pages)
elseif app.GetBookButton==1235
app.InformationTextArea.Author='Hugo';
app.InformationTextArea.Pages='416';
output(app.InformationTextArea.Author,app.InformationTextArea.Pages)
elseif app.GetBookButton==1236
app.InformationTextArea.Author='Tolstoy';
app.InformationTextArea.Pages='516';
output(app.InformationTextArea.Author,app.InformationTextArea.Pages)
elseif app.GetBookButton==1237
app.InformationTextArea.Author='John Steinbeck';
app.InformationTextArea.Pages='187';
output(app.InformationTextArea.Author,app.InformationTextArea.Pages)
elseif output('not information for author','not information')
end
end

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

採用された回答

Adam Danz
Adam Danz 2019 年 12 月 26 日
When comparing strings or char arrays, use strcmp() instead of A==B. Also, to combine conditions, use && as shown below.
if app.GetBookButton==1235 && ...
strcmp(app.InformationTextArea.Author, 'Hugo') &&...
strcmp(app.InformationTextArea.Pages, '416')
strcmp() is case-sensitive. For case insensivitity, use strcmpi().
  3 件のコメント
Esin Derin
Esin Derin 2019 年 12 月 27 日
function output = my_output(x,y)
ISBN=app.ISBNEditField.Value;
BOOKS=app.BOOKSListBox.Value;
% it affect app getbookbutton to getbookbutton
GetBook=app.GetBookButton;
Information=app.InformationTextAreaLabel.Text;
GetBook=[1234, 1235 ,1236, 1237];
% this function output the information of book
% count number of enter books
for i = 1 : length(app.BOOKSlist.Items)
if ISBN == app.BOOKSlist.Items(i)
app.InformationTextAreaLabel.Text = string(i);
break;
end
if app.GetBookButton==1234
strcmp(app.InformationTextArea.Author,'Tolstoy')
strcmp(app.InformationTextArea.Pages,'1000')
output(app.InformationTextArea.Author,app.InformationTextArea.Pages)
elseif app.GetBookButton==1235
strcmp(app.InformationTextArea.Author,'Hugo')
strcmp(app.InformationTextArea.Pages,'416')
output(app.InformationTextArea.Author,app.InformationTextArea.Pages)
elseif app.GetBookButton==1236
strcmp(app.InformationTextArea.Author,'Tolstoy')
strcmp(app.InformationTextArea.Pages,'516')
output(app.InformationTextArea.Author,app.InformationTextArea.Pages)
elseif app.GetBookButton==1237
strcmp(app.InformationTextArea.Author,'John Steinbeck')
strcmp(app.InformationTextArea.Pages,'187')
output(app.InformationTextArea.Author,app.InformationTextArea.Pages)
elseif output('not information for author','not information')
end
end
end
Adam Danz
Adam Danz 2019 年 12 月 28 日
What is the entire copy-pasted error message?
What are the values of the variables producing the error?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by