MATLAB Answers

Double = in one line of code

1 view (last 30 days)
Zeynab Mousavikhamene
Zeynab Mousavikhamene on 13 Aug 2019
Commented: James Tursa on 13 Aug 2019
Can I define a=b=c in one line of code in matlab? if yes what is the syntax?
I do not want to define in double section like a=b; c=b;

  1 Comment

James Tursa
James Tursa on 13 Aug 2019
What do you have against a=b; c=b; ?

Sign in to comment.

Answers (2)

madhan ravi
madhan ravi on 13 Aug 2019
doc deal

  0 Comments

Sign in to comment.


Andrei Bobrov
Andrei Bobrov on 13 Aug 2019
b = 1000;
zz = {b};
[a,c] = zz{[1,1]};

  1 Comment

Rik
Rik on 13 Aug 2019
Nice hack, although I think deal is more clear when reading the code. I didn't know this syntax also generated a comma-separated list like {:} does.

Sign in to comment.

Sign in to answer this question.

Tags