How do I substract like variables from each other
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a table that looks like Book1_1, I need help with figuring out if Var1 row 1 ==Var1 row 2 then subtract Var2 row 2 from Var2 row 1 and continue down till the end of the table (this subtract answer would then create a new variable but I do not need help with creating a new variable just how to subtract likes from likes). Thank you.
3 Kommentare
Zahrah Walid
am 2 Dez. 2022
I guess this is somehow similar to your problem: https://www.mathworks.com/matlabcentral/answers/18717-time-difference-between-two-sets-of-times-in-hrs-mins-and-seconds-gui-if-possible
Antworten (2)
Arif Hoq
am 2 Dez. 2022
one approach:
a=readmatrix("Book1.xlsx");
b= datetime(a,'ConvertFrom','excel');
% b(:,3)=b(:,2);
for i=1:size(b,1)-1
if b(i,1)==b(i+1,1)
c(i)=b(i+1,2)-b(i,2);
end
end
output=c'
0 Kommentare
Voss
am 3 Dez. 2022
a = readmatrix("Book1.xlsx");
b = datetime(a(:,2),'ConvertFrom','excel');
N = size(a,1);
c = duration(NaN(N,3));
for i = 1:N-1
if a(i,1) == a(i+1,1)
c(i+1) = b(i+1)-b(i);
end
end
disp(c);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!