小编Kno*_*eek的帖子

MATLAB没有足够的输入参数

我一直试图运行它并且不知道出了什么问题.我把它保存为test.m. 我在编辑器中单击运行,在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
Run Code Online (Sandbox Code Playgroud)

matlab

4
推荐指数
2
解决办法
4万
查看次数

标签 统计

matlab ×1