Comparing matrices of different dimensions
8 views (last 30 days)
Show older comments
I have 3 matrices, one is a 1x301 array,A, one is a scalar value,B, and the 3rd is 10x10x10 array,C. I need to be able to do: A-B/C.
I've tried it using meshgrid by doing: [An, Bn, Cn] = meshgrid(A,B,C) following it up by F = An - (Bn ./ Cn); so that a matrix can be output containing the values of the sum for each element.
I'm unsure whether this is the right method or the best way to go about it
2 Comments
Image Analyst
on 16 Dec 2017
I'm not sure what you want to do. A has 301 values while C has a thousand values. In what way do you want to combine them? For example, what is the last element of F? The 301st? The 1000th? What elements of A and C would go into making up the last value of F? Please spell it out explicitly.
Answers (1)
Image Analyst
on 16 Dec 2017
So what do you plan on doing with elements 302 - 1000 of C? Ignore them? And in what order do you plan on taking the first 301 elements of C?
lastElement = max([numel(A), numel(B), numel(C)]);
F = A(1:lastElement) - (B(1:lastElement) ./ C(1:lastElement));
this takes c in column major order.
0 Comments
See Also
Categories
Find more on Deep Learning Toolbox 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!