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:
Function mfile!!!

Subject: Function mfile!!!

From: Cesar

Date: 22 Aug, 2010 23:13:05

Message: 1 of 6

1)Quadratic function M-file: Write a function M-file for a function M-file myquad which takes three arguments a, b and c. The function M-file may assume that a is nonzero. It then goes through the following steps:
Create the function handle f for the function f(x) = a*x^2 + b*x + c.
Calculate the vertex x = ... and y = ... of the parabola. Make sure that these calculations do not end in semicolons so that the results do appear.
Calculate the x-intercepts using solve. Same follow-up comment as the previous question.
Use ezplot to plot the graph of the function.
Return 1 if the parabola opens up and -1 if it opens down. This can be done using a purely mathematical statement, no if command required, but you can use if if you wish.

2)Linear approximation function M-file: Write a function M-file for a function mylinear which takes three arguments f, a and b and uses linear approximation to approximate the value of f(b) using the tangent line to f at x = a. Return this approximation.

3)Natural logarithm function M-file: Write a function M-file for a function mylog which takes one argument x and calculates log(x) using quad and using the fact that the definition of the natural logarithm is that log(x) is the definite integral of 1/t from t=1 to t=x. Return this approximation.

Subject: Function mfile!!!

From: John D'Errico

Date: 22 Aug, 2010 23:32:22

Message: 2 of 6

"Cesar " <celny516@aol.com> wrote in message <i4sau1$1ui$1@fred.mathworks.com>...
> 1)Quadratic function M-file: Write a function M-file for a function M-file myquad which takes three arguments a, b and c. The function M-file may assume that a is nonzero. It then goes through the following steps:
> Create the function handle f for the function f(x) = a*x^2 + b*x + c.
> Calculate the vertex x = ... and y = ... of the parabola. Make sure that these calculations do not end in semicolons so that the results do appear.
> Calculate the x-intercepts using solve. Same follow-up comment as the previous question.
> Use ezplot to plot the graph of the function.
> Return 1 if the parabola opens up and -1 if it opens down. This can be done using a purely mathematical statement, no if command required, but you can use if if you wish.
>
> 2)Linear approximation function M-file: Write a function M-file for a function mylinear which takes three arguments f, a and b and uses linear approximation to approximate the value of f(b) using the tangent line to f at x = a. Return this approximation.
>
> 3)Natural logarithm function M-file: Write a function M-file for a function mylog which takes one argument x and calculates log(x) using quad and using the fact that the definition of the natural logarithm is that log(x) is the definite integral of 1/t from t=1 to t=x. Return this approximation.

And have you bothered to do anything about it at all?

I see that you've waited until Sunday night to post
your homework assignment. Is it due tomorrow?

John

Subject: Function mfile!!!

From: Walter Roberson

Date: 22 Aug, 2010 23:38:04

Message: 3 of 6

On 22/08/10 6:13 PM, Cesar wrote:
> 1)Quadratic function M-file: Write a function M-file for a function
> M-file myquad which takes three arguments a, b and c. The function
> M-file may assume that a is nonzero. It then goes through the following
> steps:
> Create the function handle f for the function f(x) = a*x^2 + b*x + c.
> Calculate the vertex x = ... and y = ... of the parabola. Make sure that
> these calculations do not end in semicolons so that the results do appear.
> Calculate the x-intercepts using solve. Same follow-up comment as the
> previous question.
> Use ezplot to plot the graph of the function.
> Return 1 if the parabola opens up and -1 if it opens down. This can be
> done using a purely mathematical statement, no if command required, but
> you can use if if you wish.

Sorry, I do not have the symbolic toolbox, so I would not be able to
test the 'solve' portion or anything after that, but someone else might
perhaps be able to handle that part.

Please post your school's standards on variable naming and on
indentation, the places where spaces are permitted (or forbidden), rules
on putting multiple statements per line, and on using continuation
statements. Please also post your school's standards on commenting.
Also, so that we get everything right, please post an exact copy of the
header you would need to use as comments for the assignment -- your
complete name, institute name, teacher's name, course identifier,
section identifier, your student ID, and so on, so that we can slot them
all in for you. Programs can run differently depending on the prior
comments, so for complete testing we will need to know this information
ahead of time.

Oh yes, please also indicate the exact Matlab version you are using, so
that we don't accidentally use a feature from a later version.

Subject: Function mfile!!!

From: Neil

Date: 23 Aug, 2010 00:34:22

Message: 4 of 6

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <i4sc26$cu5$1@fred.mathworks.com>...
> "Cesar " <celny516@aol.com> wrote in message <i4sau1$1ui$1@fred.mathworks.com>...
> > 1)Quadratic function M-file: Write a function M-file for a function M-file myquad which takes three arguments a, b and c. The function M-file may assume that a is nonzero. It then goes through the following steps:
> > Create the function handle f for the function f(x) = a*x^2 + b*x + c.
> > Calculate the vertex x = ... and y = ... of the parabola. Make sure that these calculations do not end in semicolons so that the results do appear.
> > Calculate the x-intercepts using solve. Same follow-up comment as the previous question.
> > Use ezplot to plot the graph of the function.
> > Return 1 if the parabola opens up and -1 if it opens down. This can be done using a purely mathematical statement, no if command required, but you can use if if you wish.
> >
> > 2)Linear approximation function M-file: Write a function M-file for a function mylinear which takes three arguments f, a and b and uses linear approximation to approximate the value of f(b) using the tangent line to f at x = a. Return this approximation.
> >
> > 3)Natural logarithm function M-file: Write a function M-file for a function mylog which takes one argument x and calculates log(x) using quad and using the fact that the definition of the natural logarithm is that log(x) is the definite integral of 1/t from t=1 to t=x. Return this approximation.
>
> And have you bothered to do anything about it at all?
>
> I see that you've waited until Sunday night to post
> your homework assignment. Is it due tomorrow?
>
> John

If anyone wants to do this guys homework for him you might be interested in reading the original questions:

http://www-users.math.umd.edu/~jow/206summer10/assignments/pr3.html

This is not a homework service

Subject: Function mfile!!!

From: Steven_Lord

Date: 23 Aug, 2010 00:56:28

Message: 5 of 6



"John D'Errico" <woodchips@rochester.rr.com> wrote in message
news:i4sc26$cu5$1@fred.mathworks.com...
> "Cesar " <celny516@aol.com> wrote in message
> <i4sau1$1ui$1@fred.mathworks.com>...

*snip*

> I see that you've waited until Sunday night to post
> your homework assignment. Is it due tomorrow?

No, Project 3 was due _last_ Sunday evening.

http://www-users.math.umd.edu/~jow/206summer10/assignments/index.shtml

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Function mfile!!!

From: cesar Lopez

Date: 23 Aug, 2010 01:20:26

Message: 6 of 6

yea it is. I have been trying all day. For number one, I keep getting a continues random things. For number two, I have no idea how to do that in mat lab. I can do it by hand.

Tags for 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