I have to write a code for doing the following steps.
- Loading a file and saving the contents of a file into a list. (the file contains one column and 1223 rows of numbers, say in Matlab code
1:1:1223
) - Automatically Splitting the list into multiple sub-lists. (say each sub-list with 100 numbers, i.e.
1223/100 = 12.23
(approximately13
sub-lists)) - Increase the step-size in a particular sublist (say sub-list no.
3
contents from201:1:300
to201:0.5:300
). - After changing a particular sub-list, joining all the list to form a single list.
I have done the first step and I am struggling to do the steps 2, 3 and 4. I am unable to find a way to implement in tcl (I am a newbie for TCL). I have created a prototype in MATLAB (esp. to explain my need in the StackOverflow community). Following is the code I've written in MATLAB. But Ultimately, I have to implement this in TCL. (Using the cell
concept in MATLAB, the whole process got easier)
clc
clear all
close all
Data_Initial = 1:1:1223;
Elements_in_List = 100;
% Dividing the list into Multiple sub-lists
Total_SubLists = floor(length(Data_Initial)/Elements_in_List);
if ((Total_SubLists*Elements_in_List) < length(Data_Initial))
Total_SubLists = Total_SubLists + 1;
end
for i = 1: Total_SubLists
Sublist_Begin_RowID = (i - 1)* Elements_in_List + 1;
Sublist_End_RowID = i * Elements_in_List;
if (i < Total_SubLists)
SubLists{i} = Data_Initial(:, Sublist_Begin_RowID:Sublist_End_RowID);
else
SubLists{i} = Data_Initial(:, Sublist_Begin_RowID:end, :);
end
end
% Changing List NO. 3
K = 3;
A = SubLists{K};
A = A(1):0.5:A(end);
SubLists{K} = A;
% Re-Joining all the list to from a New data
Data_New = [];
for i = 1:length(SubLists)
Data_New = horzcat(Data_New, SubLists{i});
end
Could anybody please help me do the steps 2, 3 and 4.