adftest function error in lagmatrix - matlab

Using the adftest function in MATLAB's econometrics toolbox, I'm receiving the following error:
>> [h1,pVal1] = adftest(y1,'model','ARD')
Error using lagmatrix (line 25)
lagmatrix: wrong # of input arguments
Error in adftest>runReg (line 705)
yLags = lagmatrix(y,0:(testLags+1));
Error in adftest (line 417)
testReg = runReg(i,y,testT,testLags,testModel,needRegOut);
y1 is a <41x1> vector of doubles.
Has anyone received this error or have any thoughts on what the issue is? I am using this code right out of the box so I'm not sure what is going on. I'd post to MATLAB's site, but it is down for maintenance.

This is either a bug in Matlab, in which case you should submit it on the Matlab support site. Before you do that, you should check that you don't have a function lagmatrix on your path that shadows the built-in function. Type
which lagmatrix
on the command line. If the path does not point to your Matlab installation, you should move lagmatrix off the Matlab search path.
Also note that y1 should not contain all NaN, or be otherwise degenerate, so you may want to check the function using the sample data as suggested in the help to be sure it's a bug and not just your data.

I had the same problem with this function. In my case, the problem was the function lagmatrix (older version) in my MATLAB path and the adftest function was the newest version. The soluction was delete the older version of lagmatrix.

Related

getpts MATLAB returns unrecognized function or variable 'getpts'

i'm trying to use getpts to choose points in the current figure using the mouse. However, when i run it, i'm getting the error "unrecognized function or variable 'getpts'."
Here's my code
for i=1:n
im = imread([read_path 'IMG_' num2str(i+t) '.jpg']); %Get image
figure
imshow(im)
[x,y] = getpts; %returns error
end
Any idea why that's happening?
Note: I'm using the free trial version of Matlab
I'd appreciate the help!
From the docs, getpts is in the image processing toolbox.
This isn't always obvious, you can infer it from the docs link itself:
mathworks.com/help/images/ref/getpts.html
(where a built-in would be something like mathworks.com/help/matlab/ref/sum.html)
You can also see it's nested under the image processing toolbox in the side-bar on that page.
In your trial installation of MATLAB you likely don't have this toolbox. You might know from the install process, or you could check whether the toolbox folder exists in the installation directory, e.g.

Error in Matlab code using rand function

I have been using the following matlab code to generate random numbers,
rand('state',0);
n=100;
m=300;
A=rand(m,n);
b=A*ones(n,1)/2;
c=-rand(n,1);
However, it keeps giving me the message "Error in ESE605_Homework_4 (line 1)
rand('state',0)'"I have tried to evaluate the problem, and it says I should switch to using the "rng" function because newer versions of Matlab discourage use of "rand". However, upon switching to the rng, function I am still having issues. Can anyone offer some help?
From Matlab documnetaion
for 'state' option you should use rng function instead of rand

Laguerre polynomials in MATLAB

I tried using the .. command in MATLAB to generate Laguerre polynomials but I keep getting this error every time:
I found this in the help section:
Since I have defined x as symbolic I shouldn't be getting this error.
Also on website I found this which says that the function does not run in MATLAB.
Can anyone help? Thanks in advance
Like you say, and the matlab help says this function only works inside mupad, maybe in later versions it works in matlab console.
If you want to use it, write mupad in Matlab Command window and then use it in the mupad, matlab will return you the result as I show in the picture
In R2014b+, there is a laguerreL function available directly from within Matlab. However, a version of this function was introduced to MuPAD in R2009a. You can call the MuPAD version from within Matlab
syms x;
feval(symengine,'laguerreL',2,x)
or
evalin(symengine,'laguerreL(2,x)')
Both return x^2/2 - 2*x + 1.
You can read more about interacting with MuPAD functionality from Matlab here. However, I'd recommend browsing and searching the archived documentation for your specific version or using your built-in HTML documentation (e.g., doc mupad or doc 'calling mupad').

MATLAB: Error in fig2texPS

I want to use fig2texPS to export plots from MATLAB to LaTeX. I copied the the script to D:\Eigene Dokumente\MATLAB\fig2TexPS and added this folder as a path in MATLAB. Unfortunately, I receive the following error:
>> fig2texPS()
Undefined function 'find' for input arguments of type 'matlab.graphics.chart.primitive.Line'.
Error in fig2texPS (line 526)
lsh = double(find(handle(lshandles),'-class','graph2d.lineseries')); % find plots
PS: I use a version of the script which was updated in order to work with pdtlatex (http://pastebin.com/xK6KxxBT) that I found in the MATLAB Central File Exchange. The same error also occurs when I use the original script.
This might not be the answer you are looking for, but there is the marvelous matlab2tikz that does the job of conversion of figures quite nicely, which you could use as an alternative to fig2texPS.
I also use the function fig2texPS.m and it works very well. It might be an answer for your question to use an older version of Matlab. I am using 2013b and it works. While I have tried this function with Matlab 2015a, I was getting the same error message.
I hope my answer helps you with your problems.

SSIM Coding Error

I have some questions. I try to follow some coding from Mathworks:
I = imread('cameraman.tif');
ssimValues = zeros(1,10);
qualityFactor = 10:10:100;
for i = 1:10
imwrite(I,'compressedImage.jpg','jpg','quality',qualityFactor(i));
ssimValues(i) = ssim(imread('compressedImage.jpg'),I);
end
I just change the image file which is a.jpg and b.jpg but I get this error from MATLAB:
Undefined function 'ssim' for input arguments of type 'uint8'
Error in SSIMTesting (line 6)
ssimValues(i) = ssim(imread('logohalal1.jpg'),i);
Why is that ? Can someone help me explain the code and the error ? Sorry because I'm new in MATLAB.
Thank you.
MATLAB release notes for the Image Processing Toolbox shows that this function was new to R2014a. If you have an older version of MATLAB, or you don't have that toolbox, you don't have it. This sort of issue can be avoided by using only examples found in the help on your local installation of MATLAB rather than the online help.
To check your version of MATLAB and installed toolboxes, type ver at the command line.
To check if a function can be found on your MATLAB path, you can use which, e.g. which ssim