Execution of script findpeaks as a function is not supported: Problem?
13 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have a problem during execting a very simple function "findpeaks".
I'm trying to excute the following script from MATLAB Documentsions:
data = [25 8 15 5 6 10 10 3 1 20 7];
plot(data)
pks = findpeaks(data)
However, I'm getting the following error:
Execution of script findpeaks as a function is not supported:
\My Documents\MATLAB\findpeaks.m
Error in untitled (line 4)
pks = findpeaks(data)
Any help on how to solve this problem!
6 件のコメント
Stephen23
2022 年 9 月 20 日
"It seems that this is only on the MATLAB version of my computer in my university. "
The error message already tells us where the problem is:
\My Documents\MATLAB\findpeaks.m
Once you rename your files, you might also need to
rehash toolboxcache
dpb
2022 年 9 月 21 日
"Once you rename your files, ..."
And, if you did the renaming by copying to another filename, you'll also have to delete the old
\My Documents\MATLAB\findpeaks.m
copy...if it's still around, even if execute the new script, it'll try to call that old one instead of the Toolbox version.
Show us what
which -all findpeaks
returns on your machine -- then for elucidation, compare that to the other machine/installation that works as expected.
回答 (1 件)
Harshit Gupta
2022 年 10 月 4 日
As per my understanding, you are trying to execute “findpeaks” function which gives the following error-
Execution of script findpeaks as a function is not supported.
The common causes for the same are listed as follows:
- You have created a script MATLAB file with the same name as a function on the MATLAB path but higher on the path than that function.
- You are attempting to index into an array that does not exist when a script file with that name exists.
Solution:
Execute
>> which -all ‹filename›
for the file specified in the error message. Verify that the file you expect to execute is being used instead of any other file with the same name. If it is not, rename or delete the files higher on the MATLAB path than the file you expect to use, or reorder the directories on your MATLAB path to place the version of the file you want to use higher than any other version.
To check whether your filename conflicts with the in-built functions, you can use “exist” command on the command prompt. The documentation for the same is given in the following link:
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!