我一直試圖運行這個,不知道發生了什麼問題。我把它保存爲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