For loop with multiple arrays
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello Everyone ,I have to determine fuel_consumption at 60,80 ,120 and maximum speed. Fuel consumption is function of sfc,powerclutch and speed which is varying and the rest are constant.How to use for loop in this condition istead of writing 4 times .Can someone advice me please !
![mtf.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/241390/mtf.png)
2 Commenti
the cyclist
il 6 Ott 2019
It's easier for us to help you if you paste your code as text (not an image of your code), because then we can copy & paste it into MATLAB for editing.
Risposte (1)
the cyclist
il 6 Ott 2019
Modificato: the cyclist
il 6 Ott 2019
You don't need a loop:
% These are tot defined in your code, so I made up some numbers
max_speed = 180;
Rho_fuel = 1;
Powerclutch = [8771.7168 14371.2576 33023.8944 242500];
speed = [60 80 120 max_speed];
sfc = [600 450 330 360];
fuelConsumption = (sfc.*Powerclutch*100/1000)./(1000*Rho_fuel*speed);
This calculates all four values in vectorized form.
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!