MATLAB: Extracting edited tables from cell array and saving them back to original variables

savingeditedcellarrays

Im sure there is a simple method for doing this but I cant seem to figure it out
I have created cell array full of pre-existing tables
myTables = {indxExt,indxFlex,lrgeDia,midExt,midFlex,pinch}
Then I loop through the myTables variable and remove the data that i do not require from each matrix in each cell and update myTables
for i = 1:length(myTables)
neg = myTables{i}(1,i)<0;
if neg == 1
data = myTables{i};
data(:,data(1,:)<0) = [];
myTables{i}=data;
end
How can I then save the new tables back to the corresponding original table?
Thanks

Best Answer

Note
if logicalvalue == 1
is the same as asking if true is true. It's a bit redundant. In addition in matlab it involves converting the logical value to double, to compare it to the double 1. The result of the comparison is then the exact same logical value you started with.
if logicalvalue
does the same more succintly and without unecessary conversions.
It doesn't look like your tables are actual matlab tables. The syntax you're using wouldn't work with tables, so I'm assuming you're using matrices.
The code you've written does store the modified matrices in the original cell array. However, you only modify said matrices, if the 1st element of column i of the ith matrix is negative. Is it really what you intended?
If you intended to delete all columns whose 1st element is negative, from all the matrices, then you don't need that if:
for i = 1:numel(myTables)
mytables{i}(:, myTables{i}(1, :) < 0) = []; %you don't even need to bother with the temporary data
end
which you can also write with a cellfun:
mytables = cellfun(@(m) m(:, m(1, :) >= 0), myTables, 'UniformOutput', false); %only keep columns whose first value is >= 0