I am currently having issues with storing the values which I read from another text file using the textscan() function.
I am trying to use the NumPts as a counter so as to help me store the values of the number of variables from the dat file.
I am currently getting an error that states: Index exceeds matrix dimensions. Error in CorrectedWheelModelDataFromTxt (line 15) MyCellNumPts{1,1}= MyCellC{4,1};
Below is an excerpt of the code:
MyCellXVal = cell(1,1000);
MyCellYVal= cell(1,1000);
MyCellZVal= cell(1,1000);
MyCellNumPts = cell(1,1);
NumPts=0;
CountPts=1;
MyCellC=cell(100,100);
fileID = fopen('WheelReflectors.dat');
MyCellC = textscan(fileID,'%d %d %d');
fclose(fileID);
MyCellNumPts{1,1}= MyCellC{4,1};
NumPts = MyCellNumPts{1,1};
while(CountPts<NumPts)
MyCellXVal{1,CountPts} =C{CountPts,1};
MyCellYVal{1,CountPts} =C{CountPts,2};
MyCellZVal{1,CountPts} =C{CountPts,3};
CountPts = CountPts +1;
end
Below contains the data of the dat file: 130 40 70 270 40 70 200 40 0 3
I don't understand why I am getting the matrix dimension issue when I am just trying to store one value. Please advise me. Appreciate your assistance.