for loop to subtract row from columns

1 回表示 (過去 30 日間)
Frederik Reese
Frederik Reese 2022 年 5 月 13 日
コメント済み: Dyuman Joshi 2022 年 5 月 13 日
Hi, probably to easy for you....
I want to substract a value column i in row 3 in a matrix of the depending column i and get a new matrix.
Matrix is 103x371
f.e. Value column 10 row 3 subtract with column 10 4:371
The values calculatet aren't right.
I think i have to implement another loop to choose also the values in the x direction (instead [4:371])
Thanks
clc
clear all
clear workspace
load ('Punkte_Gesamt_D')
Punkte_Gesamt_D(Punkte_Gesamt_D==0)=nan
for i=1:103
Punkte_Gesamt_D_Wasserhoehe (i,:)= Punkte_Gesamt_D ([i],[4:371])-Punkte_Gesamt_D(3,i);
end
  2 件のコメント
Frederik Reese
Frederik Reese 2022 年 5 月 13 日
I only needet to change
Punkte_Gesamt_D ([i],[4:371])-Punkte_Gesamt_D(i,3)
Dyuman Joshi
Dyuman Joshi 2022 年 5 月 13 日
"f.e. Value column 10 row 3 subtract with column 10 4:371"
You want to do this - matrix(4:371,10)-matrix(3,10) ?

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2022 年 5 月 13 日
編集済み: Matt J 2022 年 5 月 13 日
Punkte_Gesamt_D_Wasserhoehe([4:371],:)=...
Punkte_Gesamt_D_Wasserhoehe([4:371],:)-Punkte_Gesamt_D_Wasserhoehe(3,:);
  2 件のコメント
Frederik Reese
Frederik Reese 2022 年 5 月 13 日
Thanks for your answer, but that doesnt work for me
Matt J
Matt J 2022 年 5 月 13 日
what does it do that isn't right?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by