i want to make comparison between two matrices elements after creating the two matrices.

조회 수: 2 (최근 30일)
for i = 1:3
x{i} = rand(3,3);
end
How can you display a number say in matrix x{1} ,i want to get the number of row 2,column 3 and how can we make a comparison between matrix x{1} element and x{2} element???

답변 (2개)

Jonas
Jonas 2021년 7월 17일
편집: Jonas 2021년 7월 17일
you have access to cell entries e.g. by using x{1}(2,3); if your matrices have all the same size i would suggest saving them in an array using
x(:,:,i)= rand(3,3);
in your loop, then it is easily accessible by using conventional triple indexing. x{1}(2,3) would then be x(2,3,1)
  댓글 수: 2
chan
chan 2021년 7월 18일
Thank you Jonas for your reply. this concept i got it but how will you compare between each cell of two matrices????
Jonas
Jonas 2021년 7월 18일
it depends a bit on which element you want to comapre and how you want to compare them. if you want to compare the elements at posiiton x=3 and y =2 using a histogram you could call e.g. histogram(x(2,3,:))

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


chan
chan 2021년 7월 18일
x=rand(5,3);
for i=1:5
for j=1:3
A(i,j)=x(i,j);
end
end
this is for creating one single matrix. i want to create more than 1 matrix say 6 matrices. all the values will be using rand function.So how to create??? using x(:,:,i)=rand(3,3) i got it but when we actually want to compare elements between two matrices , how will we do???

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by