Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
logical return or out on an application

Subject: logical return or out on an application

From: wahyoe Unggul

Date: 26 Feb, 2011 10:08:29

Message: 1 of 6

how do I create a logical return or out on an application?

Subject: logical return or out on an application

From: Nasser M. Abbasi

Date: 26 Feb, 2011 10:25:16

Message: 2 of 6

On 2/26/2011 2:08 AM, wahyoe Unggul wrote:
> how do I create a logical return or out on an application?


return a boolean valued variable?

--Nasser

Subject: logical return or out on an application

From: wahyoe Unggul

Date: 26 Feb, 2011 10:51:12

Message: 3 of 6

"Nasser M. Abbasi" <nma@12000.org> wrote in message <ikakef$ube$1@speranza.aioe.org>...
> On 2/26/2011 2:08 AM, wahyoe Unggul wrote:
> > how do I create a logical return or out on an application?
>
>
> return a boolean valued variable?
>
> --Nasser

hai Nasser
I compile the following function, after running successfully.
the problem is when the election "if You Want to calculate the square area of yes = 1 or no = 2" if I choose "1" or "yes" then immediately closed the program, how if you choose "1" or "ye" program back to the initial format and if you select "2" or "no" the application will exit

example function
function square_area
disp('square_area')
l=input('input lenght');
w=input('input width');
disp(['lenght =' num2str(l)])
disp(['Width =' num2str(w)])
a=l*w;
disp(['square_area = ',num2str(a)])
d=input('if you want to calculate the square area yes =1 or no=2');
if d==1
    return
else
    close
end

Subject: logical return or out on an application

From: Nasser M. Abbasi

Date: 26 Feb, 2011 11:15:17

Message: 4 of 6

On 2/26/2011 2:51 AM, wahyoe Unggul wrote:
> "Nasser M. Abbasi"<nma@12000.org> wrote in message<ikakef$ube$1@speranza.aioe.org>...
>> On 2/26/2011 2:08 AM, wahyoe Unggul wrote:
>>> how do I create a logical return or out on an application?
>>
>>
>> return a boolean valued variable?
>>
>> --Nasser
>
> hai Nasser
> I compile the following function, after running successfully.
> the problem is when the election "if You Want to calculate the square area of
> yes = 1 or no = 2" if I choose "1" or "yes" then immediately closed the program, how if
> you choose "1" or "ye" program back to the initial format and if you select "2" or "no" the application will exit
>
> example function
> function square_area
> disp('square_area')
> l=input('input lenght');
> w=input('input width');
> disp(['lenght =' num2str(l)])
> disp(['Width =' num2str(w)])
> a=l*w;
> disp(['square_area = ',num2str(a)])
> d=input('if you want to calculate the square area yes =1 or no=2');
> if d==1
> return
> else
> close
> end


If I understand you ok, here is one way:
ps. better not to use 'l' are variable name, it looks one the
digit '1'.


-----------------
function square_area

done = false;

while not(done)
    disp('square_area')
    len = input('input lenght');
    w = input('input width');
    
    disp(['lenght =' num2str(len)])
    disp(['Width =' num2str(w)])
    
    a = len*w;
    
    disp(['square_area = ',num2str(a)])
    
    d = input('if you want to calculate the square area yes =1 or no=2');
    
    done = d==2;
end

end
---------------------

Subject: logical return or out on an application

From: wahyoe Unggul

Date: 26 Feb, 2011 11:34:31

Message: 5 of 6

Thank's Nasser M. Abbasi
for his help

Subject: logical return or out on an application

From: wahyoe Unggul

Date: 28 Feb, 2011 10:06:03

Message: 6 of 6


hi. Nasser
Is there another form or another example, to solve the above problems
thanks

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us