MATLab matrix multiplier not outputting the correct product..
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!