Error while using cellfun with a function

3 Ansichten (letzte 30 Tage)
Arkaniva Sarkar
Arkaniva Sarkar am 13 Mai 2021
Kommentiert: Star Strider am 14 Mai 2021
I am using cellfun to apply a function on train and test variables for feature extraction. The function works absolutely fine when used without cellfun but with cellfun it gives an error. The code which I'm running:
RRTrain1 = cellfun(@(x)[rrvec] == RRfeatures(x),XTrain,'UniformOutput',false);
And this is the error which is appearing,
Unrecognized function or variable 'rrvec'.
Error in @(x)[rrvec]==RRfeatures(x)
However, rrvec is already declared within RRfeatures function. Can anyone please suggest how to solve this issue?

Akzeptierte Antwort

Star Strider
Star Strider am 13 Mai 2021
Try this instead —
RRTrain1 = cellfun(@(x)RRfeatures(x),XTrain,'UniformOutput',false);
I have no idea if that will do what you want.
More importantly, if the function works fine on its own, is there a specific reason for using cellfun?
  4 Kommentare
Arkaniva Sarkar
Arkaniva Sarkar am 14 Mai 2021
I solved the issue. It did not work that way. I had to use a counter instead of a loop. That served my purpose. Thank you for your help.
Star Strider
Star Strider am 14 Mai 2021
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by