How to calculate the difference b/w elements of a matrix corresponding to any one element of a m*n matrix using loop

2 次查看(过去 30 天)
hello,
I want to calculate the difference b/w different elements of a matrix corresponging to any single element.
say, i am having any 3*4 matrix and want to calculate the difference from element [1 3] with each and every remaining lemnents of the of the matrix.
  2 个评论
Sonia Goyal
Sonia Goyal 2019-3-8
say this is the matrix A = [ a b c d; f g h i; j k l m ]
and if i want to calculate the difference from element a11 with respect to each and every remaining element of the matrix using a loop because i will have to do the same for a matrix with larger dimensions.

请先登录,再进行评论。

回答(1 个)

KSSV
KSSV 2019-3-6
A = rand(3,4) ;
iwant = A(1,3)-A(:)
  1 个评论
Sonia Goyal
Sonia Goyal 2019-3-8
Thank you for kind response sir but i have the different query.
say this is the matrix A = [ a b c d; f g h i; j k l m ]
and if i want to calculate the difference from element a11 with respect to each and every remaining element of the matrix using a loop because i will have to do the same for a matrix with larger dimensions.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by