convert array 3d array into 3 column(ranked)

1 vue (au cours des 30 derniers jours)
joms
joms le 1 Août 2019
Modifié(e) : joms le 8 Août 2019
How can i convert array 3d array into 3 column(ranked)
INPUT
SPEED=[1 2]'
TRQ=[10 20 30]
Z=[0 1;3 5; 4 3]
A=TRQ
B=SPEED'
STEP1 -Convert Table into Array
STEP2 -Sort Array based on Z
Result=[{'SPEED', 'TRQ','Z'},[2;1;2;1;2;1],[20;30;30;30;10;10],[5;4;3;3;1;0]]
  1 commentaire
Walter Roberson
Walter Roberson le 1 Août 2019
Step0 = [{'', '', 'SPEED', ''};
{'', 'Z'}, num2cell(SPEED.');
{'T'; 'R'; 'Q'}, num2cell(TRQ(:)), num2cell(Z) ];

Connectez-vous pour commenter.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 1 Août 2019
Modifié(e) : Andrei Bobrov le 1 Août 2019
SPEED=[1 2]'
TRQ=[10 20 30]
Z=[0 1;3 5; 4 3]
[x,y] = ndgrid(TRQ,SPEED);
T = array2table([y(:),x(:),Z(:)],'VariableNames',{'SPEED','TRQ','Z'});
Tout = sortrows(T,{'Z','SPEED'},{'descend','descend'})
without using table
[x,y] = ndgrid(TRQ,SPEED);
T1 = [y(:),x(:),Z(:)];
T2 = sortrows(T,[-3,-1]);
out = [{'SPEED','TRQ','Z'};num2cell(T2)];
  1 commentaire
joms
joms le 1 Août 2019
Thank you . excactly the answer i was looking for.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Produits


Version

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by