Removing duplicate entries of cell array MATLAB - arrays

I am facing a problem. i have a huge data file in text format and the entries are in this format:
18 1 1471-213X-6-54-12 503 5.333333e-001 xyz
the First column range from 1-22 and first column and third column must not be duplicated. If duplicated values exists i want to remove them. I am working in Matlab.
I could not find any suitable stuff to solve this problem.
Anybody hint/help will highly be appreciated.
Thanks in advance.
Mehdi

Here is a hint, suppose your first column is called f, and your third colum is called t.
you may be interested in the following commands:
[xxx,IA_f] = unique(f)
[xxx,IA_t] = unique(t)
[xxx,IA_tf] = unique([f t], 'rows')
Assuming that your data is in matrix'M' and you have selected IA as the proper index, you can do:
M_unique = M(IA,:)

Related

Laravel eloquent query to get records with array with specified length

It seems like this should be pretty simple to find the answer to but apparently not for me.
I need to query a count of records where the field called bullets contains an array with a length of 5. Here is what I currently have but it's checking for character length of the field itself(I believe), not of an array. Can anyone help me out please?
$vcount = Variation::where('user_id', user_id)->whereRaw('LENGTH(bullets) = 5')->count();
thanks to this thread Laravel 5.6. JSONb column. Count array
I found whereJsonLength() that worked for my use case:
$vcount = Variation::where('user_id', user_id)->whereJsonLength('bullets', '=', 5)->count();

Excel Array Functionality for Cross Check

I have 2 columns in my Excel File. First column is called Planned Q and has values separated by Comma. The second column is called Current Q and it has only one value.
As per below screen, I want to check if any of A2 value is in B2 value it should find/call a MATCH otherwise it is Mis-Match. How can I perform this task?
Thank you for your help!
Use SEARCH:
=IF(ISNUMBER(SEARCH(B2,A2)),"Match","Mis-Match")

VBA FormulaArray range class error when the Characters are less than 255

The VBA .FormulaArray seems to have a problem with my range. I've read that it can't handle over 255 characters, but mine is only about 108, but I could be understanding it wrong.
It gives an
Error 1004:
Unable to set FormulaArray property of the Range class.
I've tried leaving the formula in the table column and let it automatically populate when the table is filled with the Macro, but the problem is that the Index array table doesn't exist yet before the Macro starts running.
Also tried leaving it as text and then changing the column to "general" but it doesn't work. And I know it will create a problem changing it to an array formula this way as well.
This is the code I'm using:
With wsOutdated.ListObjects("Table_Outdated_Stock_Counts")
.ListColumns("Ranging").DataBodyRange.NumberFormat = "General"
.ListColumns("Ranging").DataBodyRange.FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([#Article]&[#Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"
End With
I need the table column to populate automatically with the array formula.
It works for other columns(they are not array formulas though and only need to match a single value).
Maybe you could try:
.ListColumns("Ranging").DataBodyRange.Cells(1, 1).FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([#Article]&[#Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"
Instead of :
.ListColumns("Ranging").DataBodyRange.FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([#Article]&[#Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"
and see if it works for you!
Explanation:
Your code is trying to write Array formula to multiple cells simultaneously which is not allowed.
If you try to do this in Excel then it will return an error "Multi-cell array formulas aren't allowed in tables".

Excel INDEX MATCH retrieves information randomly

I'm have an issue that the Excel INDEX (with double MATCH) funtion retrieves data what it seems randomly. I have the following data set (Imgur).
What it needs to do: Display the pax count on the schedule at the correct position if a match between the gatenumber (columA) and the time (row1) is found in the data list.
I used: {=IFERROR(INDEX($I$54:$I$91,MATCH($A2&I$1,$H$54:$H$91&$G$54:$G$91,0)),"")}
The issue: some values are retrieved, some not (marked in gray) without any differences in the function/data.
Remarks:
All cell formats are the same.
All cells are set as an array {}.
Increasing the Index Array to all 3 columns with the data and adding [column_num] 3 does not help.
If I change values like the time in the list some move to the correct new position, some not.
Software version is (Excel) Professional Plus 2013.
Any help on what the cause of this problem could be, a solution or an alternative method would be greatly appreciated!

return array of #NA

I have a list of item numbers.Some of them don't have details associated with them. I would like the list of item numbers that don't have info associated. they can be identified with #N/A error.
I'm running excel 2007.
i am using this array formula to return the associated details. which are in column A
=IF(ISERROR(VLOOKUP(J12,A:H,{2,3,4,5,6,7,8},FALSE)),"",VLOOKUP(J12,A:H,{2,3,4,5,6,7,8},FALSE))
if the lookup can't find the associated item number in column a it returns blanks, otherwise it returns the associated data.
the ones that error, i need a list of those.
is there a formula or a vba macro to get this information?
thanks for your time
Ian
As XORLX said: why you are using {values} as its picking items from column B?
Anyway you can change your formula with
=IFERROR(VLOOKUP(J12,A:H,{2,3,4,5,6,7,8},FALSE),"N/A")
So in case of error it will give N/A which you can later filter.
But I think you want result as in this pic
Sample File
Where
K6=IFERROR(INDEX(A:H,MATCH(J6,A:A,0),(IF(INDIRECT("B"&MATCH(J6,A:A,0))<>"",2,IF(INDIRECT("C"&MATCH(J6,A:A,0))<>"",3,IF(INDIRECT("D"&MATCH(J6,A:A,0))<>"",4,IF(INDIRECT("E"&MATCH(J6,A:A,0))<>"",5,IF(INDIRECT("F"&MATCH(J6,A:A,0))<>"",6,IF(INDIRECT("G"&MATCH(J6,A:A,0))<>"",7,IF(INDIRECT("H"&MATCH(J6,A:A,0))<>"",8))))))))),"N/A")
In my example I am looking for Joy which is in Row 2.
Now after finding Row 2 it will go and check 2nd Column B which is empty so it will go for 3rd C and so on and when will return the data from the 1st column and if find nothing then will return error.

Resources