Combinations of values in vectors
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everybody,
Here is my question: if the first logical expression is correct, depth_tot_7 will be calculated. If not, the (if correct) next logical check calculates depth_tot_5 or depth_tot_3. What I additionally want to achieve are the following two things:
a) I want to define a range from 3, 5, 7 for lam without having to specify one of these values at the beginning. It´s either 3, 5 or 7. Depending on this value, the if function shall be performed. If I define the range for lam, for some reason depth_tot_3 is calculated, while if a single value for lam is defined, the if function is performed correctly.
b) If i.ie. lam=3, I would like the program to combine all of the possible lamella depths that are contained in the regarding formula. This means that I´d like my programm to create total depths where lamellas have different attributed depths (for lam = 3 i.e. 25*2+50, 35*2+20, 50*2+35, 45*2+50 etc.). I would like to achieve that the values are differently combined to each other, considering the fact that these single lamellas have the same range and steps.
I hope that my explanation is now clear and looking forward to your answers and help.
Best regards
%span length [m]
span=3.5:0.5:7;
%Number of lamellas [-]
lam=3:2:7;
%Depth outer lamella parallel to span [mm]
lam_o_p=20:5:50;
%Depth inner lamella parallel to span [mm]
lam_i_p=20:5:50;
%Depth inner lamella cross to span [mm]
lam_i_c=20:5:50;
%Calculation of total depth [mm]
if(lam>5)
depth_tot_7=(lam_o_p)*4+(lam_i_p*2)+(lam_i_c);
elseif (lam>3)
depth_tot_5=lam_o_p*2+lam_i_p*1+lam_i_c;
else
depth_tot_3=lam_o_p*2+lam_i_c;
end
0 Commenti
Risposte (1)
Athul Prakash
il 3 Nov 2020
Hi Davide,
To answer both your questions..
a) I'm assuming that you don't want to specify 'lam' in the code (along with the if part). You may consider wrapping the calculation (the whole if body) into a function, after which the function can be called for any 'lam' from outside.
b) I'm not sure what you're trying to calculate here. Could you clarify in relation to the code you've posted?
0 Commenti
Vedere anche
Categorie
Scopri di più su Downloads 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!