MATLab matrix multiplier not outputting the correct product..
조회 수: 1 (최근 30일)
이전 댓글 표시
Probably something very basic, but I cannot see why the product is making some of the correct solutions, yet the other solution outputs 0.
Example: I placed these as my test products..
A = [2,1;3,0]
x = [2;1]
function y = myProduct(A, x)
% The command myproduct(A,x) computes the product
% of the matrix A and the vector x by column.
% Set sizes
[m, n] = size(A);
[p, q] = size(x);
% Check Dimensions
if(n == p && q == 1)
%Initializes the y vector
y = zeros(m,1);
for i = 1:m
y(n) = A(n,:)*x;
end
else
disp('Matrix Dimension Mismatch')
y = [];
end
end
댓글 수: 0
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!