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

2 views (last 30 days)
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 Comments
Sonia Goyal
Sonia Goyal on 8 Mar 2019
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.

Sign in to comment.

Answers (1)

KSSV
KSSV on 6 Mar 2019
A = rand(3,4) ;
iwant = A(1,3)-A(:)
  1 Comment
Sonia Goyal
Sonia Goyal on 8 Mar 2019
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.

Sign in to comment.

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!