フィルターのクリア

Input #2 expected to be a cell array, was struct instead.

9 ビュー (過去 30 日間)
Darshan Gade
Darshan Gade 2021 年 4 月 14 日
回答済み: Walter Roberson 2021 年 4 月 14 日
Can anyone tell what is the issue here
>> {MISRAErrorTables(fl).Table(tl).Line}
ans =
1×1 cell array
{'29'}
>> x = Code2Model
x =
struct with fields:
token: [1×1 struct]
file: [1×1 struct]
line: [1×1 struct]
begin: [1×1 struct]
sidlink: [1×1 struct]
>> {x.line.Text}
ans =
1×1 cell array
{'29'}
>> {x.file.Text}
ans =
1×1 cell array
{'Generic20kHzModule_ac.c'}
>> {[ModelName,'_ac.c']}
ans =
1×1 cell array
{'Generic20kHzModule_ac.c'}
>> LineIndex{tl} = find(cell2mat(cellfun(@(x)(strcmp({x.line.Text},{MISRAErrorTables(fl).Table(tl).Line})...
&& strcmp({x.file.Text},{[ModelName,'_ac.c']})),Code2Model,'UniformOutput',false)))
Error using cellfun
Input #2 expected to be a cell array, was struct instead.
  1 件のコメント
Daniel Pollard
Daniel Pollard 2021 年 4 月 14 日
Please format your code properly. Explain what the code does and how you expected it to work. I tried reading through what's there but it makes no sense to someone who's not you, and we can't run it because you haven't defined any of the variables.
As it happens, "Input #2 expected to be a cell array, was struct instead." is a very descriptive error message. The function expected the second input to be a cell array. You gave it a structure instead. The code errored. Since you don't explain the code, the inputs or the expected outputs, no one can help you.

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

採用された回答

Walter Roberson
Walter Roberson 2021 年 4 月 14 日
You need arrayfun() instead of cellfun() for that purpose.
This assumes that in time Code2Model will be a non-scalar struct array.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by