matlab问题?Input argument 'X' is undefined.function Y = adb(X,bd)%Y = ADB(X,bd) adds rows and/or columns by duplication on the % lower resp.right side of the input matrix% % X - input matrix% bd(1) - number of rows to add % bd(2) - number of column
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 02:37:28
matlab问题?Input argument 'X' is undefined.function Y = adb(X,bd)%Y = ADB(X,bd) adds rows and/or columns by duplication on the % lower resp.right side of the input matrix% % X - input matrix% bd(1) - number of rows to add % bd(2) - number of column
matlab问题?Input argument 'X' is undefined.
function Y = adb(X,bd)
%Y = ADB(X,bd) adds rows and/or columns by duplication on the
% lower resp.right side of the input matrix
%
% X - input matrix
% bd(1) - number of rows to add
% bd(2) - number of columns to add
%
% Y - extended matrix
% (Oliver Rockinger 16.08.99)
[z s] = size(X);
% copy interior
Y = zeros(z+bd(1),s+bd(2));
Y(1:z,1:s) = X;
% add rows
if (bd(1) > 0)
Y(z+1:z+bd(1),1:s) = X(z-1:-1:z-bd(1),1:s);
end;
% add columns
if (bd(2) > 0)
Y(1:z,s+1:s+bd(2)) = X(1:z,s-1:-1:s-bd(2));
end;
% add corner
if (bd(1) > 0 & bd(2) > 0)
Y(z+1:z+bd(1),s+1:s+bd(2)) = X(z-1:-1:z-bd(1),s-1:-1:s-bd(2));
end;
Input argument 'X' is undefined.
Error in ==> C:\MATLAB6p5\work\adb.m
On line 13 ==> [z s] = size(X);
这是什么原因?
matlab问题?Input argument 'X' is undefined.function Y = adb(X,bd)%Y = ADB(X,bd) adds rows and/or columns by duplication on the % lower resp.right side of the input matrix% % X - input matrix% bd(1) - number of rows to add % bd(2) - number of column
你不能直接运行这个adb.m文件
你需要在命令行里输入
X=[1 2 3;4 5 6;7 8 9];%具体什么 你自己定 是一个矩阵
bd=[1,2];%同样是你自己指定的
Y=adb(X,bd)
或者 你建立一个新的temp.m和abd.m在同一个目录下,文件内容为
X=[1 2 3;4 5 6;7 8 9];%具体什么 你自己定 是一个矩阵
bd=[1,2];%同样是你自己指定的
Y=adb(X,bd)
即可