Matlab &引用;错误使用/矩阵尺寸必须一致。”;创建函数系统时

Matlab &引用;错误使用/矩阵尺寸必须一致。”;创建函数系统时,matlab,debugging,math,Matlab,Debugging,Math,这就是我的目标: 这就是我作为变量插入的内容: %input all the varaible alpha= 0.33; beta= 0.96; frac= 0.01; step= 0.001; %set proper step size x0= (alpha*beta)^(1/(1-alpha))*frac; %starting point Kss= (alpha*beta)^(1/(1-alpha)); %steady state x= x0+step:step:Kss-ste

这就是我的目标:

这就是我作为变量插入的内容:

%input all the varaible 

alpha= 0.33; 
beta= 0.96;
frac= 0.01;
step= 0.001; %set proper step size

x0= (alpha*beta)^(1/(1-alpha))*frac; %starting point 
Kss= (alpha*beta)^(1/(1-alpha)); %steady state 
x= x0+step:step:Kss-step; %generated values to move the equation through the system 
这是我用来生成方程组的函数:

function [f]=sysoe(x) 

k= length(x); %length of sequence without the two 
%knwon value (the starter and the end game); this is not a number because
%you do not actually know. Instead, it's for machine to run through the
%sequence till it gets there. 

global alpha beta frac  %the factors 

T= k+2; %total length of time for capital. one generation..... n generation 
%until steady state 

Kss= (alpha*beta)^(1/(1-alpha)); %the end game steady state value 

k0= frac*Kss; %the starting level capital as a fraction of the steady 
%state capital 

K= [k0 x Kss]; %starting state, everything in the middle, steady-state. In 
%column form; which need to be transposed later. x is not a singular number
%becuase x is as many values as the system needs it to be to solve the
%question. In this case, to go from one equation to another. 

%K(1:T-2) first element in the vector & stops at the third to last element 
%K(2:T-1) second element in the vector & stops at the second to last element 
%K(3:T) third element in the vector & stops at the last element 

f= 1./(K(1:T-2).^alpha-K(2:T-1))- ((beta.*alpha.*K(2:T-1).^(alpha-1))./(K(2:T-1).^alpha-K(3:T))); 

f=f'; %turn it into a row system 
end 
这就是我在命令窗口中所说的:

[f]=sysoe(x)
然后,我收到了以下错误消息:

Error using  / 
Matrix dimensions must agree.

Error in sysoe (line 15)
Kss= (alpha*beta)^(1/(1-alpha)); %the end game steady state value

请帮忙

忘了在任何地方声明它是全局的

global alpha beta frac