Matrix manipulation such as subtraction
Show older comments
Can I ask for some help regarding matrix manipulation? Here's what I'm after. Let's say for example I have two arrays:
A = [2 3 4 5]
B = [0 1 2 3 4 5 6 7 8 9]
The output that I want is a cell containing an answer like this:
C{1} = [2-0 3-0 4-0 5-0]
C{2} = [2-1 3-1 4-1 5-1]
.
.
.
C{10} = [2-9 3-9 4-9 5-9]
Accepted Answer
More Answers (1)
José-Luis
on 19 Dec 2013
Faster:
your_mat = repmat(A,numel(B),1)-repmat(B',1,numel(A));
Categories
Find more on Creating and Concatenating 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!