How to replace values in a matrix according to the reference matrix
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Zhan
 el 21 de Mayo de 2017
  
Assume matrix A and reference matrix B as follow:
A = [
1
4
8
10
3
2
7
6
3
6
];
% in matrix B two rows has 100 difference.
B = [
1  240
2  340
3  440
4  540
5  640
6  740
7  840
8  940
9  1040
10  1140
];
I want to replace matrix A's array according to the reference matrix B.
C = [
1  240
4  540
8  940
10  1140
3  440
2  340
7  840
6  740
3  440
6  740
];
1 comentario
  Stephen23
      
      
 el 21 de Mayo de 2017
				
      Editada: Stephen23
      
      
 el 21 de Mayo de 2017
  
			@Zhan: you keep asking questions, but you have never accepted any of the answers to any of your questions. Accepting answers shows which answer solved your question, and is also an easy way for you to say "thank you" for our volunteer effort helping you.
Respuesta aceptada
  Andrei Bobrov
      
      
 el 21 de Mayo de 2017
        
      Editada: Andrei Bobrov
      
      
 el 21 de Mayo de 2017
  
      just
out = B(A,:)
or general case
[~,ii] = ismember(A,B(:,1));
out = B(ii,:);
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Logical en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


