How best to compare a columns from one set of data with columns from another?

조회 수: 3 (최근 30일)
Harry Baker
Harry Baker 2021년 10월 23일
답변: Sameer 2024년 2월 28일
I have 2 data sets where the 3 left most columns are markers for that data (ie A 1 1, A 1 2, B 1 1, etc). I need to plot the data in the 4th column in each set against each other but i dont know how to search for the matching set of 3 markers to pair the data up.
Any idea how I could do this?
  댓글 수: 2
Matt J
Matt J 2021년 10월 23일
It depends whether your data sets are in the form of a matrix or a table.
Jan
Jan 2021년 10월 23일
Please post some code, which produces a small example of the input array. "(ie A 1 1, A 1 2, B 1 1, etc)." is not clear.

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

답변 (1개)

Sameer
Sameer 2024년 2월 28일
Hi Harry,
From my understanding, you have two datasets where the first three columns serve as unique identifiers (markers) for each row, and you want to compare the values in the fourth column of both datasets by matching these identifiers.
You can achieve this using the code below:
% Example datasets
% dataSet1 = [A 1 1 value1; A 1 2 value2; ...]
% dataSet2 = [A 1 1 value1'; A 1 2 value2'; ...]
% Extract the marker columns from both datasets
markers1 = dataSet1(:, 1:3);
markers2 = dataSet2(:, 1:3);
% Extract the data columns from both datasets
data1 = dataSet1(:, 4);
data2 = dataSet2(:, 4);
% Find the matching rows
[commonMarkers, idx1, idx2] = intersect(markers1, markers2, 'rows')
% Now idx1 contains the indices of the matching rows in dataSet1
% and idx2 contains the indices of the matching rows in dataSet2
% Extract the matching data
matchedData1 = data1(idx1)
matchedData2 = data2(idx2)
% Plot the data
figure;
plot(matchedData1, matchedData2, 'o');
xlabel('Data from DataSet1');
ylabel('Data from DataSet2');
title('Plot of Matched Data');
I hope this helps!
Sameer

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by