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....

 採用された回答

Walter Roberson
Walter Roberson 2017 年 2 月 12 日

0 投票

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 件のコメント

Justin Leung
Justin Leung 2017 年 2 月 12 日
omg... omg... what a minor mistake... Thank you!!
Image Analyst
Image Analyst 2017 年 2 月 13 日
If we're done here, then please "Accept this answer".

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by