How can I assign the values of multiple variables in one line using vector notation?
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 3 Sep 2020
Modifié(e) : MathWorks Support Team
le 3 Sep 2020
Given two variables 'var1' and 'var2', the goal is to assign these variable to values 1 and 2 in one line using vector notation.
How can this be done?
Réponse acceptée
MathWorks Support Team
le 3 Sep 2020
This can be done using the function 'deal', which for the particular example would look as follows,
>> [var1, var2] = deal(1, 2)
var1 =
1
var2 =
2
For more information visit the corresponding documentation page for function 'deal',
1 commentaire
madhan ravi
le 3 Sep 2020
Modifié(e) : madhan ravi
le 3 Sep 2020
From the original question it looked like the values where char until looking into the answer. But nevertheless it’s a popular function indeed.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Whos dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!