for loop
조회 수: 2 (최근 30일)
이전 댓글 표시
Hey
I have 2 matrices, A and B, of same length and I have to create another variable C
A = goes from minimum to maximum to minimum (Fuel quantity)
B = contains prezeros and the remainder has some values
For example,
A = [1;2;3;4;5;6;7;8;9;10;9;8;7;6;5;4;3;2;1;0.5];
B = [0;0;0;0;0;0;0;0;0;0;0;0;5;7;3;2;0;0;0;0];
C = [A(1);A(2);A(3);A(4);A(5);A(6);A(7);A(8);A(9);A(10);A(11);A(12);A(13);A(14)-B(13);A(15)-B(14);A(16)-B(15);A(17)-B(16);A(18);A(19);A(20)];
The only limitation is that the value of A and B values are tacked on in the array after every iteration. What I have done so far is
C(1) = A(1);
C_difference(1) = A(2) – B(1);
But I am not sure when do you invoke the subtraction cause each time the values are tacked on in the respective array.
Thanks
Ferd
댓글 수: 3
Thomas
2012년 3월 23일
Are you finding the difference between the A and B vectors.
You do not need a loop if that is what you want.. MATLAB can perform element wise subtraction without loops.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!