how can I compare two columns from a differente table that are similar but no equal and then take the difference?

조회 수: 2 (최근 30일)
I want to sets of data, once was talking let's say one year ago, and the other one is recently, I would like to now the delta between the values but for the second set there are also new values, I tried doing something like this
clear all
clc
format short
addpath('Function')
DataFolder='Data';
%% Superstructure
[T1] = importfileC('Data\data_1.csv', 2, 7); %Importing file from a function created in matlab
[T2] = importfileC('Data\data_2.csv', 2, 8);
% T = [T1; T2]; %note the semicolon for vertical concatenation
% %or
% T = vertcat(T1, T2);
for i=1:length(T2.xmin)
if abs((T1.xmin(i)-T2.xmin(i)) < 0.50) || abs((T1.angle(i)-T2.angle(i))) < 5.0
T.delta(i) = abs(T1.length(i) - T2.length(2));
end
end
It is a triple conditional with an range, if the condition are fullfil then the next step is calculate the delta of the different longitudes
T1 T2
can arrange them in a horizontal position for the corresponding value? I mean save it in another table?
I also was thinking in create a zero matrix for the maximum size of the column but I don't know then how to put the delta value
Some ideas? thank you in advance

답변 (1개)

darova
darova 2021년 8월 15일
Here is my idea
if length(T2.min) > length(T1.xmin)
T = T1;
else
T = T2;
end
for i=1:length(T.xmin)
if abs((T1.xmin(i)-T2.xmin(i)) < 0.50) || abs((T1.angle(i)-T2.angle(i))) < 5.0
T.delta(i) = abs(T1.length(i) - T2.length(2));
end
end
  댓글 수: 2
DulceEien
DulceEien 2021년 8월 15일
hello, thank you for replying, at the end I put it in a double loop
for i=1:length(T1.xmin)
for ii=1:length(T2.xmin)
end
end
and saving in the first table, thank you so much

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by