Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

Thomas
Thomas am 30 Okt. 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

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by