How JustAnswer Works:

• Ask an Expert
• Get a Professional Answer
• 100% Satisfaction Guarantee

Ask LogicPro Your Own Question

LogicPro, Computer Software Engineer
Category: Programming
Satisfied Customers: 12629
Experience:  Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
29751445
Type Your Programming Question Here...
LogicPro is online now

Understand and explain the following function. Try to get the

Customer Question

Understand and explain the following function. Try to get the values of A when
1), n=4;
2), n=2;
3), n=10;

%%%%%%%%%%%%%%%%
function s=example1(n)
a=3;
if n<=5
A=a^(n);
elseif n<=10
A=a/n;
else
A=a+31;
end
A
%%%%%%%%%%%%%%%%
Submitted: 3 years ago.
Category: Programming
Expert:  LogicPro replied 3 years ago.
Hi
Welcome here
My Name os logicpro and I will help you.
1), n=4; then A is 81
2), n=2; then A is 9
3), n=10; then A is 0.3

Proof:
If n = 4 then following if condition will be true:
if n<=5
Since a is 3, 3 will be raised to the power 4 and result will be stored in A
so A = 3 ^ 4 = 81

If n = 2 then following if condition will be true:
if n<=5
Since a is 3, 3 will be raised to the power 2 and result will be stored in A
so A = 3 ^ 2= 9

If n = 10 then following if condition will be true:
elseif n<=10
Since a is 3, 3 will be devided by 10 and result will be stored in A
so A = 3 / 10 = 0.3 (rounded off)

You can ask me again using "For LogicPro only" at the start of your questions like other customers to get instant answers.

It will ensure that question is for me.

Please bookmark my profile page:

http://www.justanswer.com/homework/expert-logicpro/

so you can come back and ask me a question anytime.

Remember, if for any reason you are unsatisfied with my answer, we can continue the conversation until you’re satisfied and rate my answer as excellent. I can address follow up questions on original requirements at no extra charge and I’m always here to help.

Thank you for using this site!

Customer: replied 3 years ago.

hi

I wanted to know how to write it exactly in matlab program and I don't have the matlab program in my computer so I need you to solve it in matlab and copy what you typed thanks

Expert:  LogicPro replied 3 years ago.
I Also don't have the matlab program in my computer. However I have created the function in matlab file for you
Download example1.m
To call it, use
n= 4
example1(n)
n= 2
example1(n)
n= 10
example1(n)

it will show the result

Expert:  LogicPro replied 3 years ago.
Hi again,
Just following up with you to see how everything is going and if you have more questions for me.
You can ask me again using "For LogicPro only" at the start of your questions like you do to get instant answers.
It will ensure that question is for me.
Please bookmark my profile page:
http://www.justanswer.com/homework/expert-logicpro/
so you can come back and ask me a question anytime.
If you need any additional information on this answer, please don't hesitate to ask by clicking on 'Reply to Expert', and I will reply as soon as possible.
I hope you found the information in my answer helpful, and if so, please let me know, here. Thank you!
Thanks very much for using Just Answer!
Best wishes
LogicPro

What Customers are Saying:

• My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer
< Previous | Next >
• My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer
• Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C.
• This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex
• Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP
• I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin
• Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther
• Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C.

• ATLPROG

Satisfied Customers:

7260
MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
< Previous | Next >
• http://ww2.justanswer.com/uploads/SP/spatlanta2010/2011-6-23_12450_photo.64x64.gif ATLPROG's Avatar

ATLPROG

Satisfied Customers:

7260
MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
• http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

LogicPro

Satisfied Customers:

5514
Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
• http://ww2.justanswer.com/uploads/lifesaver333/2010-10-17_191349_ls.jpeg lifesaver's Avatar

lifesaver

Satisfied Customers:

936
Several years of intensive programming and application development experience in various platforms.
• http://ww2.justanswer.com/uploads/EH/ehabtutor/2012-8-2_202016_1.64x64.jpg ehabtutor's Avatar

ehabtutor

Satisfied Customers:

766
Bachelor of computer science, 5+ years experience in software development, software company owner
• http://ww2.justanswer.com/uploads/eljonis/2010-01-06_130406_eljon2.jpg Eljon's Avatar

Eljon

Satisfied Customers:

558
Founder of StockCanvas.com
• http://ww2.justanswer.com/uploads/FA/fael/2011-1-15_104041_profile500x500.64x64.jpg Rafael Martins's Avatar

Rafael Martins

Satisfied Customers:

446
Desktop, Mobile and Web Developer. 7+ years of experience. Creative solutions provider.
• http://ww2.justanswer.com/uploads/CH/chutz747/2011-11-6_14231_me.64x64.jpg The-PC-Guy's Avatar

The-PC-Guy

Satisfied Customers:

320
Extensive Knowledge in PHP, MYSQL, CSS & Javascript