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

조회 수: 4 (최근 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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by