How to do Batch Assignment

17 vues (au cours des 30 derniers jours)
Yize Wang
Yize Wang le 29 Mai 2019
Commenté : Yize Wang le 31 Mai 2019
Hello,
I am wondering whether there is a way in MATLAB to assign multiple variables with in a single line of code. What I am looking for is as something as follows,
[x,y,z]=[1,2,3]
instead of,
x = 1;
y = 2;
z = 3;
Thanks in advance!

Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 29 Mai 2019
Modifié(e) : KALYAN ACHARJYA le 29 Mai 2019
>> [x,y,z]=matsplit([1,2,3]);
Result
x =
1
y =
2
z =
3
Use matsplit custom function here
  1 commentaire
Yize Wang
Yize Wang le 31 Mai 2019
Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical 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!

Translated by