From: Bilal on
Hi,
I wanted to know how to have an infinite loop in Matlab. usually people want to avoid this but I actually want it.
I want my program to run continuously until i hit a key, for example "x". How can I manage to have the program exit upon pressing "x"?
Bilal
From: Sean on
"Bilal " <bilalhaider87(a)gmail.com> wrote in message <i1pnl8$jhf$1(a)fred.mathworks.com>...
> Hi,
> I wanted to know how to have an infinite loop in Matlab. usually people want to avoid this but I actually want it.
> I want my program to run continuously until i hit a key, for example "x". How can I manage to have the program exit upon pressing "x"?
> Bilal

while 1
%do stuff
end

Don't use x. Use ctrl+c on a PC or cmd+. on a MAC.
From: someone on
"Bilal " <bilalhaider87(a)gmail.com> wrote in message <i1pnl8$jhf$1(a)fred.mathworks.com>...
> Hi,
> I wanted to know how to have an infinite loop in Matlab. usually people want to avoid this but I actually want it.
> I want my program to run continuously until i hit a key, for example "x". How can I manage to have the program exit upon pressing "x"?
> Bilal

% Perhaps something like this:

x = 1;
while x
% insert code here
if "key is pressed"
x = 0;
end
end