MATLAB Answers

Combinations of values in vectors

2 views (last 30 days)
Davide Bertoldi
Davide Bertoldi on 27 Oct 2020
Answered: Athul Prakash on 3 Nov 2020
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 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]
%Number of lamellas [-]
%Depth outer lamella parallel to span [mm]
%Depth inner lamella parallel to span [mm]
%Depth inner lamella cross to span [mm]
%Calculation of total depth [mm]
elseif (lam>3)

Answers (1)

Athul Prakash
Athul Prakash on 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?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!