How do I assign part of a matrix to be a variable

268 vues (au cours des 30 derniers jours)
Emilee Burris
Emilee Burris le 25 Mar 2019
Commenté : Walter Roberson le 16 Jan 2020
I have a 9x10 matrix of data and I want to assign the first 3 rows to one variable then 4 through 6 rows to the second variable and then 7 through 9 to the last variable.
How do I do this while making sure I get all 10 columns in each row along with the rows?
  2 commentaires
Valerie McCarron
Valerie McCarron le 16 Jan 2020
How would this be done for columns instead of rows?
Walter Roberson
Walter Roberson le 16 Jan 2020
data=rand(9,10);%generate some random data
a=data(:,1:3);
b=data(:,4:6);
c=data(:,7:9);
d=data(:,10);

Connectez-vous pour commenter.

Réponse acceptée

Rik
Rik le 25 Mar 2019
data=rand(9,10);%generate some random data
a=data(1:3,:);
b=data(4:6,:);
c=data(7:9,:);

Plus de réponses (1)

Torsten
Torsten le 25 Mar 2019
A1 = A(1:3,:);
A2 = A(4:6,:);
A3 = A(7:9,:);

Catégories

En savoir plus sur Visual Exploration dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by