how to compare an array to a table

i have an array(A) and i want to cross refrence it to an external table that is not inputed on matlab yet.
A=
10.3000 9.5000
10.3000 9.5000
9.5000 9.5000
EXTERNAL TABLE
for the first column of A
A weight
9.5 247.74
10.3 268.4
for the second column of A
A weight
8.7 216.11
9.5 235.79
so that the end result would be
268.4 235.79
268.4 235.79
247.74 235.79
note that for each column the table changes

댓글 수: 7

Guillaume
Guillaume 2019년 5월 1일
So, how will the tables be imported and stored in matlab? One thing for sure, do not load them as individual variables.
Omar Almahallawy
Omar Almahallawy 2019년 5월 1일
well that's also a problem i'm facing hoping to find help.
Guillaume
Guillaume 2019년 5월 1일
How are the tables stored at the moment? How do you know that a particular table matches a given column of A?
Omar Almahallawy
Omar Almahallawy 2019년 5월 1일
편집: Omar Almahallawy 2019년 5월 1일
they are not stored yet
they do match, i have done it manually and it's in the results i mentioned above
Guillaume
Guillaume 2019년 5월 1일
they are not stored yet
Surely, these values come from something or somewhere. You don't just make then up as you go along.
It's difficult to answer your question if we don't have a starting point.
Omar Almahallawy
Omar Almahallawy 2019년 5월 1일
this is an engineering question. these tables are handed out to every engineer, i can not figure them out by myself.
i have the array A calculated and stored.
10.3000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 10.3000
10.3000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
10.3000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
10.3000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
9.5000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
9.5000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
9.5000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
9.5000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
8.7000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
9.5000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
8.7000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
8.7000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
8.7000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
8.7000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
8.7000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
7.9000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
7.9000 9.5000 8.7000 8.7000 8.7000 9.5000 9.5000 9.5000 9.5000
now it's a much bigger array than that.
i have an external table a hard copy for each column of this array(A)
i gave an example up above to illastrate a huge question in a massive project.
thank you
dpb
dpb 2019년 5월 1일
편집: dpb 2019년 5월 1일
These numbers look suspicously familiar from the earlier Q? Answers/459589-how-to-compare-two-arrays but we're still at a loss as to what you expect to do with hardcopy data in Matlab.
Unless you can scan it with OCR software or the like, it's essentially unreachable and may as well not even exist.
Perhaps if you actually told us what the particular tables are and the problem you're actually trying to solve one could visualize more clearly and thereby have a possible solution.

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2019년 5월 2일
편집: Guillaume 2019년 5월 2일

0 개 추천

"well that's also a problem i'm facing hoping to find help"
It's difficult for us to help you when you're being very evasive about the source of the data. Matlab is not going to read it from your mind, so it will have to come from somewhere. It can be read from excel file(s), downloaded from the web, painstakingly entered manually, but you're not telling us.
So, as it is, I'm just answering your original question and making up the data:
%demo data
A = [10.3 9.5
10.3 9.5
9.5 9.5]
tables = {table([9.5; 10.3], [247.74; 268.4], 'VariableNames', {'A', 'weight'}), ...
table([8.7; 9.5], [216.11; 235.79], 'VariableNames', {'A', 'weight'})}
assert(numel(tables) == size(A, 2), 'Number of tables does not match number of columns of A');
result = zeros(size(A));
for column = 1:size(A, 2)
[found, where] = ismember(A(:, column), tables{column}.A);
assert(all(found), 'Some elements of column %d of A not found is corresponding table', column);
result(:, column) = tables{column}.weight(where);
end

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2019년 5월 1일

편집:

2019년 5월 2일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by