matrix vector substraction
2 ビュー (過去 30 日間)
古いコメントを表示
z=[1,2,3,4,5,6,7,8;4,5,6,7,8,9,0,1;1,2,3,4,5,6,7,8;10,11,12,13,0,0,0,0];
y=[1,2,3,4];
how can i find z-y without loops thanks.
0 件のコメント
採用された回答
Sean de Wolski
2011 年 10 月 11 日
M = bsxfun(@minus,z,y')
assuming you want each row of y transpose (or column of y as it is) subtracted from each row of z. Otherwise you'll have to define how you want the subtraction to works since z/y are different sizes.
0 件のコメント
その他の回答 (2 件)
Amey
2011 年 10 月 11 日
To do matrix subtraction, dimensions of both the matrices should be same. Here its not the case. Matrix z is 4*8 while matrix y is 1*4
0 件のコメント
osman
2011 年 10 月 11 日
1 件のコメント
Sean de Wolski
2011 年 10 月 11 日
each column of y as it is, i.e. each row of y-transpose? See my answer.
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!