Clear Filters
Clear Filters

Error in legend (line 263) when using genpath

3 views (last 30 days)
I'm trying to add a toolbox to my matlab using the genpath function.
addpath(genpath('C:\Users\E1024185\Desktop\MA\fieldtrip-fieldtrip-b525618'))
However, if I run the code i get the Error "Incorrect number or types of inputs or outputs for function 'flip'." with an Error in legend (line 263). I just cannot figure out what's going on and how to fix this.
Has anyone experienced this or knows how to solve this?

Accepted Answer

Raj
Raj on 21 Feb 2024
When you use 'addpath(genpath('path_to_toolbox'))', MATLAB adds the toolbox and all its subfolders to the top of the search path. If the toolbox contains a function that has the same name as a built-in MATLAB function, the one in the toolbox will be called instead of the built-in one.
The error message you're seeing suggests that there's an issue with the 'flip' function. MATLAB has a built-in function named flip, and it's possible that the toolbox you are trying to add already has a function by the name 'flip', which is leading to a conflict
You can check for conflicts by using the 'which' command to find out which 'flip' function is being called by default. This will list all the flip functions MATLAB finds on the path, along with their locations.
which flip -all
Further if you find 'flip' function from the toolbox is causing the issue, you can consider either renaming it or removing the subfolder that contains the function from the path.
Additionally you can refer to the documentaion link of the 'which' command for better understanding-
Hope this helps!

More Answers (0)

Categories

Find more on Search Path in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!