我一直试图运行这个,不知道发生了什么问题。我把它保存为test.m.我点击编辑器和matlab命令窗口中的运行,说明没有足够的输入参数。我觉得我错过了一些非常明显的东西,但我无法发现这个问题。MATLAB没有足够的输入参数
function y = test(A, x)
%This function computes the product of matrix A by vector x row-wise
% define m number of rows here to feed into for loop
[ma,na] = size(A);
[mx,nx] = size(x);
% use if statement to check for proper dimensions
if(na == mx && nx == 1)
y = zeros(ma,1); % initialize y vector
for n = 1:ma
y(n) = A(n,:)*x;
end
else
disp('Dimensions of matrices do not match')
y = [];
end
end
您不能点击“运行”,因为它需要参数(“A”和“x”)。你需要输入'test(A,x)',在那里你希望定义一些矩阵'A'和'x'。 – JoshG79
这个问题不需要线性代数标签。 – NKN