How to replace and interchange values?

2 visualizaciones (últimos 30 días)
Triveni
Triveni el 27 de Feb. de 2016
Comentada: the cyclist el 27 de Feb. de 2016
x= [15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 0];
a = unique(x);
%Last column of x replaced by "a" i.e [ -45 -30 0 15 30 45 60 90]
y= [15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 -45;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 -30;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 0;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 15;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 30;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 45;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 60;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 90;];
value = [15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 -45;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 -30;
%row of initial guess "x" should be deleted.
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 15;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 30;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 45;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 60;
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 90;];

Respuesta aceptada

the cyclist
the cyclist el 27 de Feb. de 2016
Editada: the cyclist el 27 de Feb. de 2016
If I understand your question correctly, here is one way:
x= [15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 0];
a = unique(x);
y = repmat(x,numel(a),1);
y(:,end) = a';
value = y;
rowToRemove = find(x(end)==a);
value(rowToRemove,:) = [];
  2 comentarios
Triveni
Triveni el 27 de Feb. de 2016
Thanks....and please tell me to delete x from this too. i have to delete row matching with x? your program calculating "y". and i need value.
the cyclist
the cyclist el 27 de Feb. de 2016
I edited my answer to give you y and value as you stated.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by