creating a function with a condition set
Mostra commenti meno recenti
How do I create this function in Matlab? All of the tutorials seem to use very simple syntax in the functions.
f(t) = {
3 Commenti
Hollie Pietsch
il 16 Set 2017
Walter Roberson
il 16 Set 2017
Perhaps post an image of the formula.
Hollie Pietsch
il 16 Set 2017
Risposte (1)
Walter Roberson
il 16 Set 2017
Modificato: Walter Roberson
il 16 Set 2017
Otherwise, you need something like
function ft = f(t)
ft = nan(size(t));
mask = t >= 0 & t < 2;
ft(mask) = t(mask) - 1;
mask = t >= 2 & t < 4;
ft(mask) = 3 - t(mask);
Notice the nan: your function definition does not define any value for t outside of [0, 4) so no number can be assigned for those cases.
Categorie
Scopri di più su Vehicle Scenarios in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
