# pllllllllllllZzz ..... I need it today ;(

5 views (last 30 days)
mon mon on 26 Oct 2011
*Hi evry body :)
can U help me to answer qustion num(c)? I don't Know how can i answer it :( PlZz help me =,(*
Exercise 2:
(a) Write an m-file named cosmx.m (“COS Minus X”) that defines the function:
(x) = cos x - x
Recall that a function m-file is one that starts with the word function. In this case it should start off as
function y = cosmx ( x )
% y = cosmx(x) computes the difference y=cos(x)-x
% your name and the date
y = ???
(This is very simple(the object of this exercise is to get going.)
(c) Now use your cosmx function in the same plot sequence as above to plot cosmx and the horizontal axis on the interval -π < x < π. Hint: The horizontal axis is the line y = 0.
mon mon on 26 Oct 2011
a)
function y = cosmx ( x )
%y = cosmx(x) computes the difference y=cos(x)-x
% Name & Date
y =cos(x)-x;
end
b) in command window :
cosmx(1)
and it give me the correct result -0.4597

mon mon on 26 Oct 2011
plZz help me =,(
##### 2 CommentsShowHide 1 older comment
Daniel Shub on 26 Oct 2011
I think he may have accepted his answer prior to getting any help (with the possible exception of Amardeep's answer). It was accepted before I got involved.

Daniel Shub on 26 Oct 2011
ohhh, I know the answer ...
function y = cosmx ( x )
% y = cosmx(x) computes the difference y=cos(x)-x
% your name and the date
y = randn(size(x));
y(x == 1) = -0.4597;
Daniel Shub on 26 Oct 2011
@mon mon, you are right, I made a mistake. It should work now.

Amardeep on 26 Oct 2011
Create a function which calls cosmx which should look something like. I have left out the plotting functions and the variable arraying to create plottable data.
x = -pi
while x=< pi
y=cosmx(x)
x=x+0.01 (or whatever division resolution you want along the x axis)
end
That should be more than enough to get you along the right lines for part c.
##### 2 CommentsShowHide 1 older comment
Sean de Wolski on 26 Oct 2011
<=

mon mon on 26 Oct 2011
function y = cosmx ( x )
%y = cosmx(x) computes the difference y=cos(x)-x
% Name & Date
y =cos(x)-x;
end
Then part (b) I wrote in command window cosmx(1)
It give me correct >>>> -0.4597
but I do not know part(c) =(
##### 2 CommentsShowHide 1 older comment
mon mon on 26 Oct 2011
Daniel
Thank U very much .. =)
I do it .. <3

mon mon on 26 Oct 2011
Thanks All .. =)
##### 2 CommentsShowHide 1 older comment
mon mon on 26 Oct 2011
YyaP =)