Struct contents reference from a non-struct array object.

1 回表示 (過去 30 日間)
Asghar Ali
Asghar Ali 2017 年 4 月 9 日
コメント済み: Walter Roberson 2017 年 4 月 10 日
I am getting error in following line of code.
if(size(find(cfg.ch1==upper(str(j))),2)==0), valid=0; return; end;
and its called as: if(~checkValidGt(gt)), continue; end
Any solution please??

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 4 月 9 日
Whatever cfg is, it is not a structure or object
By the way you should consider isempty() instead of what you do with size().
You should consider
if ~any(cfg.ch1 == upper(str(j)))
  2 件のコメント
Asghar Ali
Asghar Ali 2017 年 4 月 10 日
cfg is a matlab script, where ch1 is defined.
Walter Roberson
Walter Roberson 2017 年 4 月 10 日
You cannot reference variables in another script or function.
You can execute a script to have it change the variables in the current workspace, and then you can use that value.
You can can call a function that returns a value and use that value.
You can call a function that returns a structure and assign the structure to a variable and then refer to a field in the variable.
You can define a class that has the field as a property, using the syntax you are already using.
You can define a "package" cfg that has a function ch1 that you could call upon using the syntax you have now.
However there is no way to refer to the inside of a script.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by