Too many input arguments - Error

2 ビュー (過去 30 日間)
João Carvalho
João Carvalho 2018 年 1 月 14 日
回答済み: Walter Roberson 2018 年 1 月 15 日
Hello, I would like to know the solution for this error:
Thanks

採用された回答

Matt J
Matt J 2018 年 1 月 15 日
編集済み: Matt J 2018 年 1 月 15 日
Since utilizadores is an array, it needs to be indexed. My guess is that you meant to have something like,
if isempty(utilizadores(i).username)
where i is some appropriately generated index.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 1 月 15 日
We can see from your image that utilizadores is a 1 x 3 struct rather than a 1 x 1 struct. When you name a non-scalar struct and a field name within that struct, you get "struct expansion". The effect is as if you had typed
if isempty(utilizadores(1).username, utilizadores(2).username, utilizadores(3).username)
You now need to decide what you want to do. Is the question whether some username in the struct is empty? Is the question whether they all are? Are you trying to get MATLAB to do some kind of implicit loop where it applies some code to the parts of utilizadores where the username is empty?
If you want to test whether utilizadores is empty then test that. If you want to know if some username is empty then
if any( cellfun(@isempty, {utilizadores.username}) )
If you want to know if all username are empty then
if all( cellfun(@isempty, {utilizadores.username}) )

カテゴリ

Help Center および File ExchangeScripts についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by