Effacer les filtres
Effacer les filtres

How to find value parameter in command window from m file matlab?

1 vue (au cours des 30 derniers jours)
wsiono fuihgi
wsiono fuihgi le 30 Oct 2012
how to find w0 value at command window from my m-file function below?
function Pfit=VarProb(p);
w0=p(1);
x(1)=1.15;
%Calculation of fit by constant probability w0;
L=length(p);Pfit(1)=w0;pfit(1)=w0;
for k=2:L;
pfit(k)=pfit(k-1)*x(1)*(1-(x(1)^(k-2)*w0…
end;
for k=2:L;
Pfit(k)=Pfit(k-1)+pfit(k);
end;
Additional Details
i type w0 at command window nothing appear.

Réponse acceptée

Thomas
Thomas le 30 Oct 2012
Edit your code as follows, you missed two close brackets in the pfit(k) line
function Pfit=VarProb(p);
w0=p(1)
x(1)=1.15;
%Calculation of fit by constant probability w0;
L=length(p);Pfit(1)=w0;pfit(1)=w0;
for k=2:L;
pfit(k)=pfit(k-1)*x(1)*(1-(x(1)^(k-2)*w0)) % this is edited line
end
for k=2:L;
Pfit(k)=Pfit(k-1)+pfit(k);
end
Now save the function as VarProb.m
and run it from the command line as follows
>> VarProb([0.2,0.4])
w0 =
0.20
pfit =
0.20 0.18
ans =
0.20 0.38
  2 commentaires
wsiono fuihgi
wsiono fuihgi le 30 Oct 2012
very helpful. many thx.
wsiono fuihgi
wsiono fuihgi le 30 Oct 2012
but what is 0.4 at this function?a

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by