Effacer les filtres
Effacer les filtres

copy datas, one above the others, in a new matrix

1 vue (au cours des 30 derniers jours)
Aude Rapet
Aude Rapet le 20 Nov 2016
Commenté : Aude Rapet le 20 Nov 2016
Hi! I am a beginner in matlab.
I want to copy the first two columns of my variable cnt in a new variable called o : and my 3rd column = 1 :
[i,j] = size (cnt) ;
o(:,1:2) = cnt(:,1:2) ;
o(:,3) = 1 ;
Then I have new datas from cnt2, and I want to copy the first two columns UNDER the datas I have already copied from cnt : and my 3rd column = 2 for these news datas :
[h,k] = size (cnt2) ;
o(i:i+h,1:2) = cnt2(1:h,1:2) ;
o(i:i+h,3) = 2 ;
I have this error message:
Subscripted assignment dimension mismatch.
Can you help me? Thank you! Aude

Réponse acceptée

the cyclist
the cyclist le 20 Nov 2016
In place of this ...
o(i:i+h,1:2) = cnt2(1:h,1:2) ;
o(i:i+h,3) = 2 ;
I think you intended this ...
o(i+1:i+h,1:2) = cnt2(1:h,1:2) ;
o(i+1:i+h,3) = 2 ;
  1 commentaire
Aude Rapet
Aude Rapet le 20 Nov 2016
Oh yes that's it! Thank you very much!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by