Why am I getting error while running code of mathworks website?

2 views (last 30 days)
Explorer
Explorer on 9 Feb 2016
Answered: John BG on 10 Feb 2016
load sunspot.dat
year=sunspot(:,1);
relNums=sunspot(:,2);
findpeaks(relNums,year);
xlabel('Year');
ylabel('Sunspot Number')
title('Find All Peaks');
I am getting below mentioned error. Why is it so?
Error using uddpvparse (line 122)
Invalid Parameter/Value pairs.
Error in findpeaks>parse_inputs (line 84)
hopts = uddpvparse('dspopts.findpeaks',varargin{:});
Error in findpeaks (line 59)
[X,Ph,Pd,Th,Np,Str,infIdx] = parse_inputs(X,varargin{:});
  3 Comments
Explorer
Explorer on 9 Feb 2016
I am getting same error when I tried to run another code from MATLAB Documentation .
data = [25 8 15 5 6 10 10 3 1 20 7];
plot(data)
pks = findpeaks(data)
findpeaks(data)
x = linspace(0,1,1000);
Pos = [1 2 3 5 7 8]/10;
Hgt = [4 4 4 2 2 3];
Wdt = [2 6 3 3 4 6]/100;
for n = 1:length(Pos)
Gauss(n,:) = Hgt(n)*exp(-((x - Pos(n))/Wdt(n)).^2);
end
PeakSig = sum(Gauss);
plot(x,Gauss,'--',x,PeakSig)
[pks,locs] = findpeaks(PeakSig,x);
findpeaks(PeakSig,x)
text(locs+.02,pks,num2str((1:numel(pks))'))
Is this because of older version of MATLAB? I am using MATLAB R2013a.

Sign in to comment.

Accepted Answer

John BG
John BG on 10 Feb 2016
there is a uppvparse related compiler bug fix report 452577 (release 2008b) in
I tried the sunspot.dat initial lines and work fine in R2015.
There are 4 findpeaks related bugs 650368(2010b), 582260(2010a), 452577(2008b) same as above, and 489930(2009a).
I have also tried the code you added later on and no problem in 2015.
If I were you, if not out of experience, just for the cost of a student licence, it really pays off to save a few pizzas and beer, and get MATLAB updated, really.
is this answer helping you in any way to solve your question and take the right direction, please give me a thumbs-up vote by clicking above, next to your question, thanks in advance.
John

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by