フィルターのクリア

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

1 回表示 (過去 30 日間)
wsiono fuihgi
wsiono fuihgi 2012 年 10 月 30 日
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.

採用された回答

Thomas
Thomas 2012 年 10 月 30 日
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 件のコメント
wsiono fuihgi
wsiono fuihgi 2012 年 10 月 30 日
very helpful. many thx.
wsiono fuihgi
wsiono fuihgi 2012 年 10 月 30 日
but what is 0.4 at this function?a

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by