How to make the result of the sum of two vectors in its first element turn out to be 0
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Hi. Good morning. I have two vectors A and B
A =
0 0.2880 0.5659 1.7225 2.3570 3.4754 4.5621 5.4822 5.8049 6.2209
B =
0.1000 0 0 0 -0.1000 0 0 0 0.1000 -0.1000
the sum of the two vectors would be: C =
0.1000 0.2880 0.5659 1.7225 2.2570 3.4754 4.5621 5.4822 5.9049 6.1209
What I do so that only the first element of the result in C gives me 0 ? like this
C =
0.0000 0.2880 0.5659 1.7225 2.2570 3.4754 4.5621 5.4822 5.9049 6.1209
댓글 수: 4
John D'Errico
2018년 4월 24일
The sum of those vectors does not have a zero sum for the first element. What can you do? Change the vectors, or change the result.
You really have only those two choices, since addition is pretty well defined.
You know what you want to go there, no matter what the first two elements are. So replace that first element in the result with 0. WTP?
Weyller Melo
2018년 4월 24일
Change the value of C(1).
C = A + B;
C(1)=0
Ricardo Gutierrez
2018년 4월 24일
Ricardo Gutierrez
2018년 4월 24일
답변 (1개)
Ameer Hamza
2018년 4월 24일
0 개 추천
Matrix Indexing is a very basic concept in MATLAB. You can refer here for details https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html. After adding C=A+B, set the first element to Zero as C(1)=0.
댓글 수: 1
Ricardo Gutierrez
2018년 4월 24일
이 질문은 마감되었습니다.
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!