Prev: GUIDE: 'Bring to front' moves other GUI objects
Next: How to if-else in 1 line in matlab like C --- x = (d <
From: Aui on 4 Dec 2009 00:15 I would like to do if-else in 1 line in matlab but I don't know if MATLAB has this feature. My C program is: x = (d < D0)?20:30; which is equal to if (d < D0) x = 20; else x = 30; Please suggest how can I do this for 1 line in matlab??? Thank you very much.
From: Justus Skorps on 4 Dec 2009 00:51
On 4 Dez., 06:15, "Aui " <littlebearproj...(a)gmail.com> wrote: > I would like to do if-else in 1 line in matlab but I don't know if MATLAB has this feature. > > My C program is: > > x = (d < D0)?20:30; > > which is equal to > if (d < D0) > x = 20; > else > x = 30; > > Please suggest how can I do this for 1 line in matlab??? Thank you very much. why does everyone wants to make his code unreadable? if (d < D0) x = 20; else x = 30;end; or for this special case x = (d < D0)*10+20; |