MATLAB Answers


Matrix multiply with a function

Asked by Indikatop on 22 Oct 2019
Latest activity Commented on by Andrei Bobrov
on 22 Oct 2019
i have two matrix with same columns and rows(matrix a and b). a is depth and b is land use index. each index value has a different equation and it is function of depth. i need to create a third matrix by substituting depth value to the functions.
depth d={2 3 4;7 2 5;1 2 5}
land use l={a b c;b c a;c b a}
I really appreciate your cooperation. Thank you


Show 1 older comment
It is a 3x3 matrix
on 22 Oct 2019
Why is this flagged as Unclear? It has an accepted answer.
I'm fix :)

Sign in to comment.



1 Answer

Answer by Andrei Bobrov
on 22 Oct 2019
Edited by Andrei Bobrov
on 22 Oct 2019
 Accepted Answer

i = [1:3;2,3,1;3:-1:1];
k = [.5;.78;.1];
f = [3;4;8];
d=[2 3 4;7 2 5;1 2 5];
l = k(i).*d + f(i);
l = kron(k(i),d) + kron(ones(size(i)),f(i));


Thank you Mr. Andrei for your answer. if d and i in excel or txt format how you do that?
on 22 Oct 2019
Then you need to load them as variables. I'm sure Google will be able to supply you with dozens if not hundreds of examples of how to read data from Excel to Matlab.
@Indikatop: Please attach your txt or xlsx file here and we show how it do.

Sign in to comment.