for loop
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Thomas
el 23 de Mzo. de 2012
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.
Respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!