matrix addition and substraction

{a1; a2; 0}
i want to R1-R1 and R2+R1

4 件のコメント

Chaudhary P Patel
Chaudhary P Patel 2022 年 1 月 31 日
i want to do both action at a time.
DGM
DGM 2022 年 1 月 31 日
編集済み: DGM 2022 年 1 月 31 日
What are R1 and R2? Why can't you just add them as you wrote?
Why would it matter whether they happen simultaneously or sequentially?
What are the results assigned to? Are they being assigned to each other?
What does {a1; a2; 0} have to do with this?
Chaudhary P Patel
Chaudhary P Patel 2022 年 1 月 31 日
R1 and R2 are row 1 and row 2.
Chaudhary P Patel
Chaudhary P Patel 2022 年 1 月 31 日
Actually it is a 15X1 matrix of {a1;a2;0;a1;a2;0.....................;a1;a2;0}
so i want to do a1-a1 and a2+a1 for each set

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

回答 (1 件)

KSSV
KSSV 2022 年 1 月 31 日
編集済み: KSSV 2022 年 1 月 31 日

0 投票

@pramod kumar What ou ask is a very basic question. I would suggest you to take a basic introductory course in MATLAB.
Your question is simple.
% random matrix for demo
a1 = rand(15,1) ;
a2 = rand(15,1) ;
% add
a = a1+a2 ;
% subtract
b = a1-a2 ;

5 件のコメント

Chaudhary P Patel
Chaudhary P Patel 2022 年 1 月 31 日
Sir, my question is not to substract one matrix to another matrix.
I want to do R2= row2+row1
and R1= row1-row-1
KSSV
KSSV 2022 年 1 月 31 日
% random matrix for demo
a1 = rand(15,1) ;
a2 = rand(15,1) ;
id1 = 1:length(a1)-1 ;
id2 = 2:length(a1) ;
a = a1(id1)+a1(id2) ;
b = a1(id1)-a1(id2) ;
Chaudhary P Patel
Chaudhary P Patel 2022 年 1 月 31 日
編集済み: KSSV 2022 年 1 月 31 日
c=rand(15,1);
for i=1:3:length(c)
a= c(i+1,1)+c(i,1);
b=a(i,1)-a(i,1);
end
is it correct, Sir?
KSSV
KSSV 2022 年 1 月 31 日
This will throow error. It will not yun, as a is a scalar and you are trying to access it a svector.
Chaudhary P Patel
Chaudhary P Patel 2022 年 1 月 31 日
sir,
7.9710
7.9710
0
7.9710
7.9710
0
7.9710
7.9710
0
7.9710
7.9710
0
7.9710
7.9710
0
this is my column matrix and i have to 1,4,7,10,13 as zero by and 2, 5,8,11,14 row be Row2+row1, row5+row4, row8+row7, row11+row10, row14+row13.

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

製品

タグ

質問済み:

2022 年 1 月 31 日

コメント済み:

2022 年 1 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by