フィルターのクリア

Looping matrice column by subtraction

1 回表示 (過去 30 日間)
Young Lee
Young Lee 2018 年 10 月 21 日
編集済み: madhan ravi 2018 年 10 月 21 日
I have a 84x7 matrices. On the entire column 2 and 4, they need to be subtracted from higher number - lower and loop through the whole 84 rows and put them into a new 84x1 vector. How can this be done? let 4x4 matrix a = [x 3 2 y; x 4 1 y; x 1 6 y; x 2 7 y; x 5 1 y;
b= [3-2 4-1 6-1 7-2 5-1]
b= [1 3 5 5 4 ]
  1 件のコメント
madhan ravi
madhan ravi 2018 年 10 月 21 日
A small example? And your desired output?

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

採用された回答

madhan ravi
madhan ravi 2018 年 10 月 21 日
編集済み: madhan ravi 2018 年 10 月 21 日
EDIT 2
a = randi([0 9],84,7) %fake data to test
a1=a(:,2) %column you want to extract
a2=a(:,5) %column you want to extract
a=[a1 a2] %two columns stored in a matrix , sorry I missed this line which caused the error
idx = find(a1<a2)
a(idx,:)=fliplr(a(idx,:))
b = a(:,1) - a(:,2) % as column vector
b1 = b' %row vector
  12 件のコメント
Young Lee
Young Lee 2018 年 10 月 21 日
thanks for your patience and help :)
madhan ravi
madhan ravi 2018 年 10 月 21 日
編集済み: madhan ravi 2018 年 10 月 21 日
Anytime:)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by