Undefined function for input type 'cell'

Hello,
I've encountered an interesting problem while making functions which I was not experiencing before. I've been going through my code to generalize it and separate it into more manageable sections by creating functions, and in one function I just created it I am getting the error
Undefined function 'myFunction' for input arguments of type 'cell'.
Which is strange because up to this point my custom functions have been not giving me this error when I pass a cell array to them and the code within the function should handle the cell array just fine, but the error seems to be rejecting the input all together any way without doing any operations on it since the error appears to be generated from the input being purely of a type cell.
Does anyone have any experience with such errors? Why should one pop up now when my other functions can handle cell arrays just fine?
Thanks for any help.

5 件のコメント

dpb
dpb 2018 年 4 月 29 日
Where's the Crystal Ball Toolbox when we need it?
Only seeing at least the prototype for myFunction will give a klew...
Andrew Chen
Andrew Chen 2018 年 4 月 29 日
Here is the first section of the code:
function [metricPercentCorrect,aestKNN,bestKNN] = tabulateKNN(predictLabels,numLetters)
%%Check KNN Labels
labels = {'alef','beh','teh','theh','jeem','hah','khah'...
,'dal','thal','reh','zain','seen','sheen','sad','dad'...
,'tah','zah','ain','ghain','feh','qaf','kaf','lam','meem'...
,'noon','heh','waw','yeh'};
for a = 1:3
for b = 1:11
for c = 1:10
tabulate = zeros(size(predictLabels{a,b,c},1),1);
for g = 0:numLetters-1
for i = 1:size(predictLabels{a,b,c},1)/numLetters
tabulate(i+(size(predictLabels{a,b,c},1)/numLetters)*g) = strcmp(labels{g+1},...
predictLabels{a,b,c}{i+(size(predictLabels{a,b,c},1)/numLetters)*g});
end
end, clear g i
for g = 0:numLetters-1
pCorrect(g+1) = sum(tabulate(((size(tabulate,1)/numLetters)*g)+1:...
(size(tabulate,1)/numLetters)*(g+1)))/(size(tabulate,1)/numLetters);
end, clear g
tabulateCell{a,b,c} = tabulate;
percentCorrect{a,b,c} = pCorrect;
end
end
end, clear a b c h tabulate
the input predictLabels is a 3D cell array and I index it with a, b and c below the 'labels' character array. I am running this function in a script I have called mainScript and the error message is generating the error in mainScript not in the tabulateKNN function which indicates to me that for whatever reason the input of type cell does not allow the function to execute.
Thanks for any help.
dpb
dpb 2018 年 4 月 30 日
Well, as suspected, the prototype was the minimum; the other possibility is a path or spelling problem...what does
which tabulateKNN
return?
If that succeeds and returns the expected result, then need to see a sample case that exhibits the symptom including error message in context. Ideal would be to supply a small working (in the sense it runs and creates the issue) example...you can attach m-file and .mat file for the necessary data.
What does _whi
Andrew Chen
Andrew Chen 2018 年 4 月 30 日
Thanks for the help dpb. It was a path problem. Sometimes it's the small things we forget to check and take for granted that end up being a problem. Thanks for the help though!
dpb
dpb 2018 年 4 月 30 日
That's what was the which would show...once it was clear there wasn't something done in the function statement that was dependent upon calling class...I didn't (and don't) recall if the wording is slightly different for the extant function w/o a class variant from the totally missing or not which is why asked for function prototype info first...

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

 採用された回答

Andrew Chen
Andrew Chen 2018 年 4 月 29 日

0 投票

Well I have to say this is a bit embarrassing but I somehow managed to save the function in a directory other than the one it should have been in. Once moving the function to the proper directory everything worked fine.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCall C++ from MATLAB についてさらに検索

製品

質問済み:

2018 年 4 月 29 日

コメント済み:

dpb
2018 年 4 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by