Data Processing in a Cell
Hello,
I have imported data into two tables T1 and T2 34243X4 and 1070X8. To Compare the two tables I have padded T2 with string ’empty’ in all columns to match rows of T1. I am comparing T2(:,2) with T1(:,1) and which ever matches I then automatically the that particular row element in 4th Col of T2 will match row element of 1st Col in T1 (This acts as Sanity Check).
All the info in both the table is in string format including numbers
when I tried to use ismember is not able to match.
Did String Compare is not working or not comaring correctly.
Please could someone guide me. I have attached my code/script and also screenshots of my data.
Thank you for your time
PN = importdata("Part Number Summary 20260220.xlsx");
opts = detectImportOptions("Sai_MFGParts_03202026_v2.xlsx", Sheet="Export Worksheet");
% Adjust options if needed, for example set data range:
opts.DataRange = "A2";
T1 = readtable("Sai_MFGParts_03202026_v2.xlsx",opts);
T2 = PN.Summary;
C = T2; % rename for clarity
headers = C(1,1:8);
data = C(2:end,1:8);
varNames = matlab.lang.makeValidName(headers);
T2 = cell2table(data, ‘VariableNames’, varNames);
Part_Number_Data_T2 = T2.PartNumber;
Product_Description_T2 = T2.ProductDescription;
Supplier_T2 = T2.Supplier;
Categoty_T2 = T2.Category;
idx = length(T1.BWC_PART);
Part_Number_Data_T2 = resize(Part_Number_Data_T2,idx); % resize to match T1(34243×4)
Product_Description_T2 = resize(Product_Description_T2,idx);
Supplier_T2 = resize(Supplier_T2,idx);
Categoty_T2 = resize(Categoty_T2,idx);
idx_2 = cellfun(‘isempty’,Part_Number_Data_T2);
idx_3 = cellfun(‘isempty’,Product_Description_T2);
idx_4 = cellfun(‘isempty’,Supplier_T2);
idx_5 = cellfun(‘isempty’,Categoty_T2);
%Replace empty entries in Product_Description_T2, Supplier_T2, and
%Categoty_T2 with string ’empty’.
Part_Number_Data_T2(idx_2) = {’empty’};
Product_Description_T2(idx_3) = {’empty’};
Supplier_T2(idx_4) = {’empty’};
Categoty_T2(idx_5) = {’empty’};
%Ensure T2 columns are column vectors
Part_Number_Data_T2 = Part_Number_Data_T2(:);
Product_Description_T2 = Product_Description_T2(:);
Supplier_T2 = Supplier_T2(:);
Categoty_T2 = Categoty_T2(:);
Ind = cell(size(T1.BWC_PART));
for k = 1:length(Ind)
Ind{k} = T1(strcmp(T1.BWC_PART,Part_Number_Data_T2{k}),:);
endHello,
I have imported data into two tables T1 and T2 34243X4 and 1070X8. To Compare the two tables I have padded T2 with string ’empty’ in all columns to match rows of T1. I am comparing T2(:,2) with T1(:,1) and which ever matches I then automatically the that particular row element in 4th Col of T2 will match row element of 1st Col in T1 (This acts as Sanity Check).
All the info in both the table is in string format including numbers
when I tried to use ismember is not able to match.
Did String Compare is not working or not comaring correctly.
Please could someone guide me. I have attached my code/script and also screenshots of my data.
Thank you for your time
PN = importdata("Part Number Summary 20260220.xlsx");
opts = detectImportOptions("Sai_MFGParts_03202026_v2.xlsx", Sheet="Export Worksheet");
% Adjust options if needed, for example set data range:
opts.DataRange = "A2";
T1 = readtable("Sai_MFGParts_03202026_v2.xlsx",opts);
T2 = PN.Summary;
C = T2; % rename for clarity
headers = C(1,1:8);
data = C(2:end,1:8);
varNames = matlab.lang.makeValidName(headers);
T2 = cell2table(data, ‘VariableNames’, varNames);
Part_Number_Data_T2 = T2.PartNumber;
Product_Description_T2 = T2.ProductDescription;
Supplier_T2 = T2.Supplier;
Categoty_T2 = T2.Category;
idx = length(T1.BWC_PART);
Part_Number_Data_T2 = resize(Part_Number_Data_T2,idx); % resize to match T1(34243×4)
Product_Description_T2 = resize(Product_Description_T2,idx);
Supplier_T2 = resize(Supplier_T2,idx);
Categoty_T2 = resize(Categoty_T2,idx);
idx_2 = cellfun(‘isempty’,Part_Number_Data_T2);
idx_3 = cellfun(‘isempty’,Product_Description_T2);
idx_4 = cellfun(‘isempty’,Supplier_T2);
idx_5 = cellfun(‘isempty’,Categoty_T2);
%Replace empty entries in Product_Description_T2, Supplier_T2, and
%Categoty_T2 with string ’empty’.
Part_Number_Data_T2(idx_2) = {’empty’};
Product_Description_T2(idx_3) = {’empty’};
Supplier_T2(idx_4) = {’empty’};
Categoty_T2(idx_5) = {’empty’};
%Ensure T2 columns are column vectors
Part_Number_Data_T2 = Part_Number_Data_T2(:);
Product_Description_T2 = Product_Description_T2(:);
Supplier_T2 = Supplier_T2(:);
Categoty_T2 = Categoty_T2(:);
Ind = cell(size(T1.BWC_PART));
for k = 1:length(Ind)
Ind{k} = T1(strcmp(T1.BWC_PART,Part_Number_Data_T2{k}),:);
end Hello,
I have imported data into two tables T1 and T2 34243X4 and 1070X8. To Compare the two tables I have padded T2 with string ’empty’ in all columns to match rows of T1. I am comparing T2(:,2) with T1(:,1) and which ever matches I then automatically the that particular row element in 4th Col of T2 will match row element of 1st Col in T1 (This acts as Sanity Check).
All the info in both the table is in string format including numbers
when I tried to use ismember is not able to match.
Did String Compare is not working or not comaring correctly.
Please could someone guide me. I have attached my code/script and also screenshots of my data.
Thank you for your time
PN = importdata("Part Number Summary 20260220.xlsx");
opts = detectImportOptions("Sai_MFGParts_03202026_v2.xlsx", Sheet="Export Worksheet");
% Adjust options if needed, for example set data range:
opts.DataRange = "A2";
T1 = readtable("Sai_MFGParts_03202026_v2.xlsx",opts);
T2 = PN.Summary;
C = T2; % rename for clarity
headers = C(1,1:8);
data = C(2:end,1:8);
varNames = matlab.lang.makeValidName(headers);
T2 = cell2table(data, ‘VariableNames’, varNames);
Part_Number_Data_T2 = T2.PartNumber;
Product_Description_T2 = T2.ProductDescription;
Supplier_T2 = T2.Supplier;
Categoty_T2 = T2.Category;
idx = length(T1.BWC_PART);
Part_Number_Data_T2 = resize(Part_Number_Data_T2,idx); % resize to match T1(34243×4)
Product_Description_T2 = resize(Product_Description_T2,idx);
Supplier_T2 = resize(Supplier_T2,idx);
Categoty_T2 = resize(Categoty_T2,idx);
idx_2 = cellfun(‘isempty’,Part_Number_Data_T2);
idx_3 = cellfun(‘isempty’,Product_Description_T2);
idx_4 = cellfun(‘isempty’,Supplier_T2);
idx_5 = cellfun(‘isempty’,Categoty_T2);
%Replace empty entries in Product_Description_T2, Supplier_T2, and
%Categoty_T2 with string ’empty’.
Part_Number_Data_T2(idx_2) = {’empty’};
Product_Description_T2(idx_3) = {’empty’};
Supplier_T2(idx_4) = {’empty’};
Categoty_T2(idx_5) = {’empty’};
%Ensure T2 columns are column vectors
Part_Number_Data_T2 = Part_Number_Data_T2(:);
Product_Description_T2 = Product_Description_T2(:);
Supplier_T2 = Supplier_T2(:);
Categoty_T2 = Categoty_T2(:);
Ind = cell(size(T1.BWC_PART));
for k = 1:length(Ind)
Ind{k} = T1(strcmp(T1.BWC_PART,Part_Number_Data_T2{k}),:);
end matlab, data processing MATLAB Answers — New Questions









