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

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2017년 2월 12일

댓글:

2017년 2월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by