全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 MATLAB等数学软件专版
6814 15
2011-01-08
这是程序原文:
function z = bigshow (varargin)

%  function z = bigshow (a,b)
%  function z = bigshow (a,b,tsim,timpulse)
% This function takes a ARMA process of the form:
%
% a*y_t = b*w_t
%
%  and graphs a simulation, the impulse response,
%  and the spectrum.
%  e.g., for
%  y_t = .9 y_{t-1} + w_t
%  the input vectors would be:
%
%  a=[1 -.9]; and b=1;
%
%  The function would then be called:
%  
%  >> bigshow (a,b)

%a=[1 -.99]; b=1;  %  near random walk
%a=[1 0 0 0 -.8]; b=1;  %
%a=[1 -.8]; b=[1 -.7];  % muth process
%a=[1 -1.3 +.7]; b=1;    %  business cycle process

% Set up the input variables.

if nargin < 2 | nargin >4
   error ('Error.  Wrong number of input arguments.')
else
   if nargin == 4
      timpulse = varargin{4};
   else
      timpulse = 26;
   end;
   if nargin >= 3;
      tsim = varargin{3};
   else
      tsim = 70;
   end
   a = varargin{1};
   b = varargin{2};
end;

% first generate the simulation (Gaussian errors)
nn=100;   % number of observations to be discarded
u=randn(tsim+nn,1);
y=filter(b,a,u);
subplot(2,2,1),
axis ([0 tsim -Inf Inf]);
plot(y(nn+1:length(y)));
title ('Simulation');

%  Now generate the impulse response

subplot(2,2,2);
nn=timpulse;
y2=dimpulse(b,a,nn);
xx=[0:nn-1];  % fix the x axis to start at zero
y2=y2(1:nn);
%axis ([0 timpulse -Inf Inf]);
plot(xx',y2)
axis ([0 timpulse -Inf Inf]);

title ('Impulse Response')

%  Now generate the spectrum

n=256;
subplot(2,2,3);
%axis ([0 pi -1 1]);
[spect2,f2]=shownew(b,a,n);
title ('Log Spectrum')
运行后显示:??? Error using ==> bigshow
      Error.  Wrong number of input arguments.

请高人帮我看看吧,真的非常感谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-1-11 14:11:26
M-files函数的自变量输入少了,小于2个或大于4个自变量都显示出错。从程序看,你还需要设定  a = varargin{1};
   b = varargin{2}
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-1-11 15:18:11
呵呵,你似乎没明白这个程序怎么用。它说明中有例子,比如第一个例子,你应当这样用:
在Matlab命令对话框输入以下命令:
a=[1 -.9]; b=1;
bigshow (a,b)
Matlab会画个图出来给你看的。
附件列表
untitled.jpg

原图尺寸 19.23 KB

untitled.jpg

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-1-11 16:05:53
太感谢上楼的朋友了,我对MATLAB了解的不错,看来我的好好学习下
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-1-11 22:14:18
不客气,共同学习。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-1-11 22:16:00
Sargent 的这本书还是有些挑战性的,如果你有什么心得,可以交流一下,让我们分享。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群