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