c=[0 0 0 0]
c = 1×4
0 0 0 0
a=[1 0 1 0]
a = 1×4
1 0 1 0
b=[0 1 1 0]
b = 1×4
0 1 1 0
b-a
ans = 1×4
-1 1 0 0
c(find((b-a)>0))=1
c = 1×4
0 1 0 0
if element a==0 and element b==1 i want to change element c in =1
Anyone can me suggest a best method to do this

 採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 9 月 4 日
編集済み: Dyuman Joshi 2023 年 9 月 4 日

0 投票

c=[0 0 0 0];
a=[1 0 1 0];
b=[0 1 1 0];
c = (a==0)&(b==1)
c = 1×4 logical array
0 1 0 0
%simplified
c = (~a)&b
c = 1×4 logical array
0 1 0 0
Given the questions you have asked recently, I would strongly recommend you to take the free MATLAB Onramp tutorial to learn the essentials of MATLAB.

その他の回答 (0 件)

カテゴリ

質問済み:

2023 年 9 月 4 日

編集済み:

2023 年 9 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by