logic question regarding two vectors
이전 댓글 표시
The two vectors, x=[0, -4, 7, 0, -1, 2], y=[1, -4, 8, 0, 1, 6] are given. Explain how matlab could reutrn...z = x and (not y)
답변 (2개)
Really have no idea what you are asking.... just guessing
x=[0, -4, 7, 0, -1, 2];
y=[1, -4, 8, 0, 1, 6];
z=min(x,y)
댓글 수: 8
Sami Ahmed
2022년 9월 8일
x=[0, -4, 7, 0, -1, 2];
y=[1, -4, 8, 0, 1, 6];
z=x&~y
z=(x&y)|(~x)
Note, x and y vectors can be converted to logical vectors: anynumbers not zero are logical 1, otherwise logical zero
logical(x)
logical(y)
Walter Roberson
2022년 9월 8일
This was obviously a homework question though...
Sami Ahmed
2022년 9월 8일
Sami Ahmed
2022년 9월 8일
Walter Roberson
2022년 9월 8일
We discourage volunteers from giving complete code for homework questions, as we find that when we do that, often the people do not learn the techniques, and instead mostly copy the answer given. We encourage the volunteers to instead answer in ways that teach the concepts, leaving the people asking the questions to apply the concepts to arrive at the answer.
Sami Ahmed
2022년 9월 8일
Sami Ahmed
2022년 9월 8일
Walter Roberson
2022년 9월 8일
0 개 추천
The "or" operation for vectors is written as the | operator.
The "and" operation for vectors is written as the & operator.
The "not" operation for vectors is written as the ~ operator.
Note that for the purpose of MATLAB, a value is considered true if it is non-zero (except that it is an error to apply logical tests directly to NaN values.)
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

