Here is the issue? In first iteration, when i=1;
temp_data=data_final(find(data_final(:,2)==i),:);
Does not find any data, which fulfil the condition "data_final(:,2)==i", here for 1st iteration, the condition is data_final(:,2)==1, hence it return the empty data aray ([ ]), i.e. after the line execute temp_data=[ ];
Next line, when the code execute to access the empty data at the following line
t_len=temp_data(end,1)+1;
here you are trying to acess the temp_data as 2D array. temp_data(end,1)>> Try to acess the data element from temp_data which having last row & 1 column, which actually doesnot have, hence it reflects error
>> temp_data(end,1)
Subscript indices must either be real positive integers or logicals.
More examples:
- temp_data as non empty (non error)
>> temp_data=[3 4 5];
>> t_len=temp_data(end,1)+1
t_len =
4
2. temp_data as empty (error)
>> temp_data=[];
>> t_len=temp_data(end,1)+1
Subscript indices must either be real positive integers or logicals.
If temp_data is non empty
Solutions: Ensure that temp_data return non empty.
Hope this have sufficient clues to get rid off the error.
Best Answer