I'm trying to delete rows of a table, when both values of 2 specific columns are equal to zeros. I've tried to use ismember(col1 & col2, 0),:)=[]; but it deletes the rows when only one of the column is zero.
Ideally, i would also like to do the opposite: delete every rows where the cells of these 2 columns aren't both zero.
I know it would be easier if I wasn't using a table, unfortunately there is some needed variables that aren't numeric.
It would be great if you know a way to do what i need with a table.
Cheers
Related
I have a table (L-arrival) of 279 rows and 252 columns. Only the first column has values while others are just NaN. The cells in the first column have multiple values (i.e. some have 1, some have 4 number of values). First of all, I am trying to select a single maximum value from each cell of the first column so that I can have a column of a single value for each cell only. Then I want to do this in a loop so that for every new value that I get, they are sorted and only the maximum values are chosen. Finally, I want to make a collection of these values obtained from multiple runs for each cell. Can anyone suggest to me how it can be approached in MatLab?I tried using the following code but didn't work well.
for b=1:279
m = numel(cell2mat(L_arrival(b,1)));
g(b)=mat2cell([cell2mat(g(b)); cell(L_arrival(b,1))]',[1 2]);
end
I'm trying to create a calculated field that sums rows of data where two columns are both missing data. I'm trying this:
SUM( INT( ISNULL( [Column1] ) AND ISNULL( [Column2] ) ) )
However, this gives me very odd results. In one example, I'm getting a result of 882 with the code above where there are a total of 35 rows, where only 10 rows are missing values. I've tried many variations, I'm always getting way too high numbers. The columns in question contains strings, so ZN() won't work. Changing aliases don't seem to make any difference.
What (probably simple) thing am I missing?
Edit: After comments - removing the sum in the CF and then re-adding it as an aggregation makes no difference. Yes, it is a combination of two database tables. The following is the table view without the sum in the CF:
Red is column 2 and pink is column 1. So the CF definitely shows something different for the blank rows, but I can't figure out why it ends up with 99 and 45 (and why sometimes one and sometimes the other). Ideally, I should be getting just 1s and 0s. Green are unique IDs.
Let's assume the following:
A=rand(10,5);
How can I replace the first 3 rows of this table with NaN's, without the matrix losing its original dimension 10x5? Thanks in advance
Just index into the first three rows but ensure you select all of the columns and replace the entries with nan:
A(1:3,:) = nan;
I have a minor comment. The variable A is not a table, but it is a matrix. Please ensure you use the right terminology from now on, as someone may confuse what you're saying with the actual table construct.
following problem:
I have a very large matrix and several rows share the same identifier in column 1. For these rows I need to do some averaging, reformatting etc.
Currently I am identifying all unique identifier values in column 1 by using the function unique and then do averaging, reformatting of values in other columns within this loop for each set of rows sharing the same column 1 value within a loop.
ID = unique(data.1);
for i = 1:length(ID);
do stuff
end
I guess this is highly inefficient and slow but I cannot think of a better way of handling this.
I want to know please how can I fill in a table, row by row, by numbers, and then to color in each row the cell that has the higher number in it.
I searched the web a little and found this "set(handles.uitable2, 'Data', {5,6,4})" but this is not helping me because i need to fill in row by row, and in this method the row data is been replace.
this is the table. as you see there is 7 rows and 10 columns. in each columns there is the correlation score of the plate digit against the samples digits (0-9).
this is how I call the correlation function[scores] = compute_corr(digit); I'm executes this call 7 times for each plate digit. scores is an array that saves in each call the correlation scores and digit is one digit from the plate.
thanks in advance.
I don't believe there's a way to update the data incrementally. So you should maintain an array containing your data, update that row by row, and call set(...,'Data',actualData) when it changes.