フィルターのクリア

How to make an endless calculated matrix?

4 ビュー (過去 30 日間)
Sebastian Ciuban
Sebastian Ciuban 2013 年 4 月 13 日
For example I have matrix A(3,2) = [2 3; 4 5; 6 7] and matrix B(3,1) = [A(1,1)+A(1,2); A(2,1)+A(2,2); A(3,1)+A(3,2)]
Now, maybe I want to add 2 more rows in matrix A and I want B calculate those element without me writing A(4,1)+A(4,2) etc, automatically. For matrix A of ,,n" rows and 2 columns I want to make a B matrix of ,,n" rows and 1 column, B depending on A. Is there some set of commands to make this possible?
EDIT: What I really need is to know how to build matrix B ,which depends on A, using functions.
For example, we got: -*matrix* A(3,2)*= [2 3; 4 5; 6 7] -a function to calculate: sqrt(A(1,1)+A(1,2))/2 -*matrix* B(3,1)= [Function(A(1,1),A(1,2)); Function(A(2,1),A(2,2)); Function(A(3,1),A(3,2))] Now how can I build matrix B regardless of rows that matrix A have, without my input for every row in matrix B *Note: English is not my first language and I may not be very explicit.
Thank you!

採用された回答

Andrei Bobrov
Andrei Bobrov 2013 年 4 月 13 日
編集済み: Andrei Bobrov 2013 年 4 月 13 日
A = [2 3; 4 5; 6 7];
B = sum(A,2);
A(end+1,:) = [4 9]
B(end+1,:) = sum(A(end+1,:),2);
ADD
fun = @(x)sqrt(sum(x,2))/2;
B= fun(A);
  1 件のコメント
Sebastian Ciuban
Sebastian Ciuban 2013 年 4 月 13 日
Thank you, indeed in this case it really works. What I really need is to know how to build matrix B ,which depends on A, using functions.
For example, we got: -*matrix* A(3,2)*= [2 3; 4 5; 6 7] -a function to calculate: sqrt(A(1,1)+A(1,2))/2 -*matrix* B(3,1)= [Function(A(1,1),A(1,2)); Function(A(2,1),A(2,2)); Function(A(3,1),A(3,2))] Now how can I build matrix B regardless of rows that matrix A have, without my input for every row in matrix B

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by