Access cell array from input in function

Hello,
I have a function which recieves a cell array but when I want to access it I get an error Undefined function 'atomsStuct' for input arguments of type 'logical'.(even though it exists in my Workspace and the data is okay)
In this example I want to get from my input atomsStruct only the rows in which matchingResNameCells equals 1, for example if matchingResNameCells = {1,1,0,0,1} I want to return rows 1,2,5.
Thank you in advance.
function [wantedAtoms] = atomExtractionBySpecificMaterial(atomsStruct,material)
%Output the atoms that belongs to the specified material in the input
resNameCells={atomsStruct.resName}
%Remove leading and trailing whitespace from resNameCells
newResNameCells =strtrim(resNameCells);
%Creates a Cell array that indicates what resName have the input material
matchingResNameCells = strcmp(material,newResNameCells)
%Output wanted atoms with matching material
wantedAtoms= atomsStuct(matchingResNameCells)
end

回答 (1 件)

Matt J
Matt J 2023 年 3 月 7 日
編集済み: Matt J 2023 年 3 月 7 日

1 投票

You have misspelled atomsStruct in this line:
wantedAtoms= atomsStuct(matchingResNameCells)

3 件のコメント

Walter Roberson
Walter Roberson 2023 年 3 月 7 日
Hah, you are right!
Shany
Shany 2023 年 3 月 8 日
thank you all for your help!
Matt J
Matt J 2023 年 3 月 8 日
You're welcome, but please Accept-click the answer to indicate the issue is resolved.

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

カテゴリ

ヘルプ センター および File ExchangeFile Operations についてさらに検索

質問済み:

2023 年 3 月 7 日

コメント済み:

2023 年 3 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by