write a matrix from a function (say h(m,n), where m and n are running index)

조회 수: 1(최근 30일)
Suppose I want to write a matrix from a function (h(m,n)), so in mathematica, It can be written in foollowing way " Table[h[m, n], {m, 1, 3}, {n,1, 3}];" this will wrtie a matrix of 3x3, how to do the same thing in matlab ??


José-Luis 2017년 8월 30일
편집: José-Luis 2017년 8월 30일
myFun = @(x,y) x.^2 + y;
result = bsxfun(myFun,1:3,(1:3).')
If I understood your question right, then you'd just need to replace myFun with your own function.
  댓글 수: 4

댓글을 달려면 로그인하십시오.


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!

Translated by