shellychard
2008-12-30, 13:33
在运行下面的程序时,老出错,提示如下:
?? One or more output arguments not assigned during call to 'F:\matlabwork\JC\invstat.m (invstat)'.
Error in ==> JCex2 at 23
[Unu(I),Usgm(I)]=[invstat(Types(I),nu(I),sgm(I))];
主程序如下:
function [] = JCex2()
clear all; clc
% Fk--- function of limit state
% dFk--- differetial of Fk
nVar=3; % number of random variable
syms x1 x2 x3 x4 x5 x6 x7 % x1 =R x2 = NG x3=NL
Fki=input('Input function equation:','s'); %'x1-x2-x3';
Fk=eval(Fki); Svs=findsym(Fk);
eVs=sym(Svs);
nVar=length(eVs);
for I=1:nVar
dFk(I)=diff(Fk,eVs(I));
end
% random variable characteristics
%Types=input(['Input distribution types of ',Svs,': '],'s');
Types=input(['Input type of random variable ',Svs,': '],'s');
nui=input(['Input meam valus of ',Svs,': '],'s');
sgmi=input(['Input std valus of ',Svs,': '],'s');
nu=deal(str2num(nui));
sgm=deal(str2num(sgmi));
%$ loop nVar
for I=1:nVar
[Unu(I),Usgm(I)]=invstat(Types(I),nu(I),sgm(I));
end
子程序如下:
function [pa,pb] = invstat(type,nu,sgm)
sgms type nu sgm
switch 'type'
case 'beta'
case 'Beta'
pa = nu ; pb = sgm;
case 'bino'
case 'Binomial'
pa = nu ; pb = sgm;
% 'chi2' or 'Chisquare',
% 'exp' or 'Exponential',
case 'ev'
pb = sqrt(6.) * sqrt(sgm) / pi;
pa = nu - psi(1) * pb; % -psi(1) is euler's constant
case 'Extreme Value'
pb = sqrt(6.) * sqrt(sgm) / pi;
pa = nu - psi(1) * pb; % -psi(1) is euler's constant
% 'f' or 'F',
% 'gam' or 'Gamma',
% 'gev' or 'Generalized Extreme Value',
% 'gp' or 'Generalized Pareto',
% 'geo' or 'Geometric',
% 'hyge' or 'Hypergeometric',
case 'evv'
pb = (pi/sqrt(6)) ./ sqrt(sgm);
pa = nu + psi(1) / pb; % -psi(1) is euler's constant
case 'logn'
% vxR = sgm/mu;
% pb = sqrt(log(1+vxR^2));
% pa = log(mu/sqrt(1+vxR^2));
s2 = 2.*log((sgm+nu^2)^(1/2)/nu);
pb = sqrt(s2);
pa = log(nu^2/(sgm+nu^2)^(1/2));
case 'Lognormal'
s2 = 2.*log((sgm+nu^2)^(1/2)/nu);
pb = sqrt(s2);
pa = log(nu^2/(sgm+nu^2)^(1/2));
% 'nbin' or 'Negative Binomial',
% 'ncf' or 'Noncentral F',
% 'nct' or 'Noncentral t',
% 'ncx2' or 'Noncentral Chi-square',
case 'norm'
pa = nu ; pb = sqrt(sgm);
case 'Normal'
pa = nu ; pb = sqrt(sgm);
% 'poiss' or 'Poisson',
% 'rayl' or 'Rayleigh',
% 't' or 'T',
% 'unif' or 'Uniform',
% 'unid' or 'Discrete Uniform',
% 'wbl' or 'Weibull'.
otherwise
disp('such random variable type is not defined!');
end
到底是怎么回事啊?搞了好久都没有搞定啊?请大家帮帮忙啊!
?? One or more output arguments not assigned during call to 'F:\matlabwork\JC\invstat.m (invstat)'.
Error in ==> JCex2 at 23
[Unu(I),Usgm(I)]=[invstat(Types(I),nu(I),sgm(I))];
主程序如下:
function [] = JCex2()
clear all; clc
% Fk--- function of limit state
% dFk--- differetial of Fk
nVar=3; % number of random variable
syms x1 x2 x3 x4 x5 x6 x7 % x1 =R x2 = NG x3=NL
Fki=input('Input function equation:','s'); %'x1-x2-x3';
Fk=eval(Fki); Svs=findsym(Fk);
eVs=sym(Svs);
nVar=length(eVs);
for I=1:nVar
dFk(I)=diff(Fk,eVs(I));
end
% random variable characteristics
%Types=input(['Input distribution types of ',Svs,': '],'s');
Types=input(['Input type of random variable ',Svs,': '],'s');
nui=input(['Input meam valus of ',Svs,': '],'s');
sgmi=input(['Input std valus of ',Svs,': '],'s');
nu=deal(str2num(nui));
sgm=deal(str2num(sgmi));
%$ loop nVar
for I=1:nVar
[Unu(I),Usgm(I)]=invstat(Types(I),nu(I),sgm(I));
end
子程序如下:
function [pa,pb] = invstat(type,nu,sgm)
sgms type nu sgm
switch 'type'
case 'beta'
case 'Beta'
pa = nu ; pb = sgm;
case 'bino'
case 'Binomial'
pa = nu ; pb = sgm;
% 'chi2' or 'Chisquare',
% 'exp' or 'Exponential',
case 'ev'
pb = sqrt(6.) * sqrt(sgm) / pi;
pa = nu - psi(1) * pb; % -psi(1) is euler's constant
case 'Extreme Value'
pb = sqrt(6.) * sqrt(sgm) / pi;
pa = nu - psi(1) * pb; % -psi(1) is euler's constant
% 'f' or 'F',
% 'gam' or 'Gamma',
% 'gev' or 'Generalized Extreme Value',
% 'gp' or 'Generalized Pareto',
% 'geo' or 'Geometric',
% 'hyge' or 'Hypergeometric',
case 'evv'
pb = (pi/sqrt(6)) ./ sqrt(sgm);
pa = nu + psi(1) / pb; % -psi(1) is euler's constant
case 'logn'
% vxR = sgm/mu;
% pb = sqrt(log(1+vxR^2));
% pa = log(mu/sqrt(1+vxR^2));
s2 = 2.*log((sgm+nu^2)^(1/2)/nu);
pb = sqrt(s2);
pa = log(nu^2/(sgm+nu^2)^(1/2));
case 'Lognormal'
s2 = 2.*log((sgm+nu^2)^(1/2)/nu);
pb = sqrt(s2);
pa = log(nu^2/(sgm+nu^2)^(1/2));
% 'nbin' or 'Negative Binomial',
% 'ncf' or 'Noncentral F',
% 'nct' or 'Noncentral t',
% 'ncx2' or 'Noncentral Chi-square',
case 'norm'
pa = nu ; pb = sqrt(sgm);
case 'Normal'
pa = nu ; pb = sqrt(sgm);
% 'poiss' or 'Poisson',
% 'rayl' or 'Rayleigh',
% 't' or 'T',
% 'unif' or 'Uniform',
% 'unid' or 'Discrete Uniform',
% 'wbl' or 'Weibull'.
otherwise
disp('such random variable type is not defined!');
end
到底是怎么回事啊?搞了好久都没有搞定啊?请大家帮帮忙啊!