Subscripted assignment dimension mismatch. What should i do?

2 views (last 30 days)
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....

Accepted Answer

Walter Roberson
Walter Roberson on 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.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!