Adding data to two matrices for indexing
显示 更早的评论
I have 2 matrices Z and Y, both are a 10x1300 matrix and consists of random numbers, how do i add data to the left and right of each element and then use indexing to find Y for a certain value of Z
For example,
Z [10 1300]
Y [10 1300]
One element in Z:
Z(1,1)=10
z=Z(1,1)
Add data to left and right side,
z-3,z-2,z-1,z,z+1,z+2,z+3
Final result: 7,8,9,10,11,12,13
Similar for Y but with different data additions
One element in Y:
Y(1,1)=20
y=Y(1,1)
Add data to left and right side,
y+3,y+2,y+1,y,y+1,y+2,y+3
Final result: 23,22,21,20,21,22,23
Use indexing to find Z=7 then find the respective element from Y would give Y= 23,
Y(find(Z==7))=23
Z=8,Y=22
Z=9,Y=21
Z=10,Y=20
Z=11,Y=21
Z=12,Y=22
Z=13,Z=23
2 个评论
I have no idea what it is you're asking. Your explanation is really unclear. Let's start with some smaller Y and Z, e.g. given:
Z = [10 7 9
15 1 23];
and
Y = [20 1 13
5 7 9];
what exact result do you want (and how do you get at it)?
result = [? ? ?
? ? ?];
Is it even a matrix the same size as Y and Z that you want as a result?
Joseph Lee
2017-11-8
编辑:Joseph Lee
2017-11-8
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!