I cannot use "binornd" or "random" function

조회 수: 8 (최근 30일)
César Guillermo Rendón Mayorga
Hi
I'm writting a code for a homework but I cannot use the "binornd" function to generate random numbers with a binomial distribution. The program shows me the next message: "Undefined function 'binornd' for input arguments of type 'double'." Then, I tried with "random" function and the program shows me "Undefined function 'random' for input arguments of type 'char'." The same situation happened with "makedist" function.
I was reading in this forum and I understood that maybe is a license problem, but I don't know how to fix it (By the way, I renewed my license file yesterday).
Below I write my code. And thanks for any help!
%%%%%Condiciones iniciales
Phi=0.95;
n=50;
P0=1;
x0=sqrt(P0)*randn(1,1);
Q0=0.1;
w0=sqrt(Q0)*randn(1,1);
x(1)=Phi*x0+w0;
%%%%Estado%%%%%%
for k=1:n
Q(k)=0.1;
w(k)=sqrt(Q(k))*randn(1,1);
x(k+1)=Phi*x(k)+w(k);
end
%%%Observaciones
R0=0.5;
p=0.5;
v0=sqrt(R0)*randn(1,1);
g0=binornd(1,p);
z0=g0*x0+v0;
for k=1:n
R(k)=0.5;
v(k)=sqrt(R(k))*randn(1,1);
g(k)=binornd(1,p);
z(k)=g(k)*x(k)+v(k);
end

채택된 답변

Steven Lord
Steven Lord 2022년 9월 5일
Both binornd and random are functions in Statistics and Machine Learning Toolbox. Do you have this toolbox installed and licensed? To check if it is installed use the ver function. From the behavior you described you likely do not have it installed.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by