for loop
3 ビュー (過去 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!