Calculation of a column
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Ke Yeun Yong
el 19 de Sept. de 2023
Comentada: Voss
el 19 de Sept. de 2023
Hi,
I have a column with 53 rows of different numbers. I only want to do formula calculation until the 45th row and the remaining 8 rows I want to make them the same value. All the results will be compile in the same column. May I know how that can be done?
With Altitude having the column (53 rows of number),
To = 288.15; % Temperature in ISA [K]
for i = 1:53
Ta (i) = To-0.0065*Altitude(i); % Temperature at altitude [K]
end
From above code, how do I make the calculation stop at 45th row and the remaining 8 rows will have the value of 216.65? and all new 53 rows of values will be under 1 column?
Thank you very much.
0 comentarios
Respuesta aceptada
Voss
el 19 de Sept. de 2023
To = 288.15; % Temperature in ISA [K]
% pre-allocate Ta to be the same size as Altitude (53x1), with all elements 216.65
Ta = 216.65*ones(size(Altitude));
% calculate the first 45 elements of Ta:
Ta(1:45) = To-0.0065*Altitude(1:45); % Temperature at altitude [K]
4 comentarios
Voss
el 19 de Sept. de 2023
Use ./ for element-wise division.
Cl = (6*CDO)./(A+B);
See the tables of operators here: https://www.mathworks.com/help/matlab/matlab_prog/array-vs-matrix-operations.html
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Types 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!