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

조회 수: 3 (최근 30일)
mon mon
mon mon 2011년 10월 26일
*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.)
(b) Now use your cosmx function to compute cosmx(1). Your result should be about -0.4597.
(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.
  댓글 수: 4
Daniel Shub
Daniel Shub 2011년 10월 26일
Great, so show us the function and then show us what you have done for part c.
mon mon
mon mon 2011년 10월 26일
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
mon mon 2011년 10월 26일
plZz help me =,(
  댓글 수: 2
Image Analyst
Image Analyst 2011년 10월 26일
How generous of you to accept your own "answer" instead of someone else who helped you.
Daniel Shub
Daniel Shub 2011년 10월 26일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

Daniel Shub
Daniel Shub 2011년 10월 26일
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;
  댓글 수: 3
mon mon
mon mon 2011년 10월 26일
Thanks Daniel ,
But it give me an Error ,too. =(
Daniel Shub
Daniel Shub 2011년 10월 26일
@mon mon, you are right, I made a mistake. It should work now.

댓글을 달려면 로그인하십시오.


Amardeep
Amardeep 2011년 10월 26일
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
mon mon
mon mon 2011년 10월 26일
thanXx Amardeep =)
but it give me ERROR =(
Sean de Wolski
Sean de Wolski 2011년 10월 26일
<=

댓글을 달려면 로그인하십시오.


mon mon
mon mon 2011년 10월 26일
my Answer in part (a)
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
Daniel Shub
Daniel Shub 2011년 10월 26일
If I asked you to evaluate cosmx at -pi, 0, and pi, how would you do that. What about if I asked you to evaluate cosmx between -pi and pi with steps of 0.01. Do you know how to plot anything?
try
doc plot
mon mon
mon mon 2011년 10월 26일
Daniel
Thank U very much .. =)
I do it .. <3

댓글을 달려면 로그인하십시오.


mon mon
mon mon 2011년 10월 26일
Thanks All .. =)
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 10월 26일
Is the question finished?
mon mon
mon mon 2011년 10월 26일
YyaP =)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by