Combining data from other variable
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have two variables names ad below
Parameters={
'' 'c1' 'c2' 'c3'
Par1 'PSO' 'SPSO' 'MPSO'
Par2 'SPSO' 'PSO' 'MPSO'
Par3 'MPSO' 'PSO' 'PSO'
Par4 'MPSO' 'MPSO' 'MPSO'
Par5 'SPSO' 'PSO' 'PSO' }
Variables={
'' c1' 'c2' 'c3'
Par1 'P' 'P' 'P'
Par2 'S' 'S' 'S'
Par3 'M' 'M' 'M'
Par4 'P' 'S' 'S'
Par5 'S' 'M' 'M'}
I have seen some posts posted by Pat,but i could not get the following result, I want to combine variables as shown below ,please help
Result{1,1}
'' c1' 'c2' 'c3'
Par1 'P' 'P' 'P'
Par2 'SPSO' 'PSO' 'MPSO'
par3 'MPSO' 'PSO' 'PSO'
Par4 'MPSO' 'MPSO' 'MPSO'
Par5 'SPSO' 'PSO' 'PSO'
Result{2,1}
Par2 'S' 'S' 'S'
Par3 'MPSO' 'PSO' 'PSO'
Par4 'MPSO' 'MPSO' 'MPSO'
Par5 'SPSO' 'PSO' 'PSO'
Result{3,1}
Par3 'M' 'M' 'M'
Par4 'MPSO' 'MPSO' 'MPSO'
Par5 'SPSO' 'PSO' 'PSO'
Result{4,1}
Par4 'P' 'S' 'S'
Par5 'SPSO' 'PSO' 'PSO'
please provide assistance
0 comentarios
Respuesta aceptada
Andrei Bobrov
el 27 de Ag. de 2012
Editada: Andrei Bobrov
el 27 de Ag. de 2012
P={
'' 'c1' 'c2' 'c3'
'Par1' 'PSO' 'SPSO' 'MPSO'
'Par2' 'SPSO' 'PSO' 'MPSO'
'Par3' 'MPSO' 'PSO' 'PSO'
'Par4' 'MPSO' 'MPSO' 'MPSO'
'Par5' 'SPSO' 'PSO' 'PSO' };
V={
'' 'c1' 'c2' 'c3'
'Par1' 'P' 'P' 'P'
'Par2' 'S' 'S' 'S'
'Par3' 'M' 'M' 'M'
'Par4' 'P' 'S' 'S'
'Par5' 'S' 'M' 'M'};
R = cell(size(P,1)-2,1);
for jj = 1:numel(R)
R{jj} = [V(1,:);V(jj+1,:);P(jj+2:end,:)];
end
OR
X = num2cell(V(2:end-1,:),2);
Y = num2cell(triu(ones(size(P,1)-[2 0]),2) > 0,2);
R = cellfun(@(x,y)[P(1,:);x;P(y,:)],X,Y,'un',0);
3 comentarios
Walter Roberson
el 27 de Ag. de 2012
I could not tell which part of that were meant literally and which parts were intended to be text.
Más respuestas (0)
Ver también
Categorías
Más información sobre Particle Swarm 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!