Putting for loop values into a matrix/array for plotting
Show older comments
I am trying to find the optimum length of a bridge with regards to cost. I'm trying to put the values from each loop into an array/matrix so I can then find the correspoding road and bridge lengths for the lowest cost on each cost ratio, however the answers from each loop are "seperate" from all other loops and I need them in one array. Does anyone know if this is possible, and if so how I would be able to do this I'm struggling to figure out how it can be done. Thanks.
Ly = 8.7 %total length ravine
Lx = 1.1 %width of ravine
Cs = 1e6 %cost of road per km
for r = 1.1:0.5:5 %varying ratio between road cost per km and bridge cost per km
Ls = 0.1:0.1:8.6; %varying length of road
Lb = sqrt((Ly-Ls).^2 + Lx.^2); %equation to find length of bridge from the length of road
C =((r*Cs)*(Lb))+(Cs*Ls); %equation for total cost of bridge and road
min(C) %minimum value of C for each ratio loop
end
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!