二つの数字の引き算

6 次查看(过去 30 天)
海
2022-10-24
编辑: Atsushi Ueno 2022-10-24
写真のように、数字が2秒ごとに列に並んでいるのですが、全ての列を引き算するプログラミングは作れるでしょうか?
例えば、写真でいうと(35.01-33.69)、(35.24-33.91)、(35.55-33.92).......のように全ての列を引き算したいです。

回答(1 个)

Atsushi Ueno
Atsushi Ueno 2022-10-24
编辑:Atsushi Ueno 2022-10-24
TT = {datetime(2022,10,24,12,06,29), 33.69, 33.91, 33.92, 33.29; % 6列目以降は省略
datetime(2022,10,24,12,06,30), 35.01, 35.24, 35.55, 34.72}
TT = 2×5 cell array
{[24-Oct-2022 12:06:29]} {[33.6900]} {[33.9100]} {[33.9200]} {[33.2900]} {[24-Oct-2022 12:06:30]} {[35.0100]} {[35.2400]} {[35.5500]} {[34.7200]}
diff = cellfun(@minus,TT(2,:),TT(1,:),'uni',false) % 2行目から1行目を引く
diff = 1×5 cell array
{[00:00:01]} {[1.3200]} {[1.3300]} {[1.6300]} {[1.4300]}

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!