Subscripted assignment dimension mismatch. What should i do?

So basically I downloaded the data provided by my professor and somehow when I worked on creating 2 coloumn for x, it said "Subscripted assignment dimension mismatch" and i got stuck... Here are my steps,
>> Y(:,1)=mgtndvi(:,1)
Y =
0.0485
-0.1794
0.1378
0.0124
0.0723
0.1893
0.1344
0.1159
0.1765
0.1340
0.1504
0.1257
-0.0646
>> mgtndvi=dlmread('mgt-ndvi0082-2.txt')
mgtndvi =
0.0485 4.2091
-0.1794 5.2015
0.1378 3.4137
0.0124 4.3957
0.0723 3.0455
0.1893 2.3837
0.1344 3.0349
0.1159 3.0462
0.1765 2.9660
0.1340 3.5063
0.1504 2.5861
0.1257 3.7062
-0.0646 4.5121
>> X(:,1)=ones(12,1)
X =
1
1
1
1
1
1
1
1
1
1
1
1
>> X(:,2)=mgtndvi(:,2) Subscripted assignment dimension mismatch.
and if I changed X into Y, it works
>> Y(:,2)=mgtndvi(:,2)
Y =
0.0485 4.2091
-0.1794 5.2015
0.1378 3.4137
0.0124 4.3957
0.0723 3.0455
0.1893 2.3837
0.1344 3.0349
0.1159 3.0462
0.1765 2.9660
0.1340 3.5063
0.1504 2.5861
0.1257 3.7062
-0.0646 4.5121
I am not sure whats going on....

 Respuesta aceptada

You have
X(:,1)=ones(12,1)
which creates X as having 12 rows. You then try to
X(:,2)=mgtndvi(:,2)
but mgtndvi has 13 rows, not 12.

2 comentarios

omg... omg... what a minor mistake... Thank you!!
If we're done here, then please "Accept this answer".

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Preguntada:

el 12 de Feb. de 2017

Comentada:

el 13 de Feb. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by