2D Matrix calculation

5 views (last 30 days)
tg295
tg295 on 29 Jun 2018
Answered: Star Strider on 29 Jun 2018
Hi there,
Fairly new to neuron.
If A is a 1000x1 vector containing non-integer values,
B is a 1000x1 vector also containing non-integer values,
and x is a vector containing integers from 1-36
How would I best go about calculating the following 1000x36 matrix,C:
C(A,B,x) = A/x + B/x
Fyi A and B are changing in time, and values of x are points in space (along an x-axis). So im wanting to see how the values at each point in space are changing over time, with 1000 time samples.
So maybe it should be written like this instead:
C(t,x) = A(t)/x + B(t)/x
Many thanks

Answers (1)

Star Strider
Star Strider on 29 Jun 2018
I would use bsxfun.
These produce the same result:
C1 = bsxfun(@mrdivide, A, x) + bsxfun(@mrdivide, B, x);
C2 = bsxfun(@rdivide, A, x) + bsxfun(@rdivide, B, x);

Categories

Find more on Matrices and Arrays 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!