How to extract the first row and first column of an array of matrix?

25 vues (au cours des 30 derniers jours)
Mr. NailGuy
Mr. NailGuy le 16 Nov 2017
Commenté : Mr. NailGuy le 16 Nov 2017
I have an array of 10001 elements of which a 2x2 matrix is inside each element. How can I loop thru the array and extract the first row, first column of each matrix?
Will appreciate your feedback.
  4 commentaires
Stephen23
Stephen23 le 16 Nov 2017
Modifié(e) : Stephen23 le 16 Nov 2017
@Mr. NailGuy: your array description is wildly inaccurate. The screenshot clearly shows that your array has size 2x2x10001, which means that it actually has 40004 elements.
You might like to consider revising basic MATLAB terminology, if you want to communicate effectively with regular MATLAB users.
Mr. NailGuy
Mr. NailGuy le 16 Nov 2017
Yeah, I might have wrong understanding of the terminology but I already resolve it. Thanks

Connectez-vous pour commenter.

Réponse acceptée

Birdman
Birdman le 16 Nov 2017
a=randi([1 10],2,2,10001);%a numeric array
row=a(1,:,:);
column=a(:,1,:);
  4 commentaires
Birdman
Birdman le 16 Nov 2017
Reshape it to plot.
elements=reshape(elements,1,10001)
Mr. NailGuy
Mr. NailGuy le 16 Nov 2017
Thanks now working fine.

Connectez-vous pour commenter.

Plus de réponses (1)

KL
KL le 16 Nov 2017
Use squeeze,
all_first_elements = squeeze(your_matrix(1,1,:));
now, plot like you normally do,
plot(all_first_elements)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by