how to fill a 2D array using for loops with given ranges
Afficher commentaires plus anciens
so i am given a problem in which i have a range for speed and density and i need to create an mxn matrix that contains the values of the power, by varying the air speed in the range of 15 m/s < V < 35 m/s and the air density range of 1.11 kg/m3 < density < 1.29 kg/m3. the power is given by a formula between speed and density. but i don't know how to fill this particular array whose dimensions are 19 rows (for the density) by 21 columns (for the speed). any suggestions ? Below is my attempt to try and fill the array.
height = input('enter the height of the car in meters: ');
width = input('enter the width of the front of the car in meters: ');
frontal_area = height * width;
v = [15:35];
roh = [1.11:0.01:1.29];
k = 0;
l = 0;
p = [];
for k = 1:length(v)
for l = 1:length(roh)
p = 0.2 * roh(l) * v(k).^3 * frontal_area
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!