Subscripted assignment dimension mismatch. What should i do?

2 Ansichten (letzte 30 Tage)
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....

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 12 Feb. 2017
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 Kommentare
Justin Leung
Justin Leung am 12 Feb. 2017
omg... omg... what a minor mistake... Thank you!!
Image Analyst
Image Analyst am 13 Feb. 2017
If we're done here, then please "Accept this answer".

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by