pllllllllllllZzz ..... I need it today ;(
显示 更早的评论
*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 个评论
Sean de Wolski
2011-10-26
What have YOU done to solve YOUR homework problem?
mon mon
2011-10-26
Daniel Shub
2011-10-26
Great, so show us the function and then show us what you have done for part c.
mon mon
2011-10-26
采纳的回答
更多回答(4 个)
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 个评论
Sean de Wolski
2011-10-26
@Daniel, that's clearly not accurate to enough floating points :(
mon mon
2011-10-26
Daniel Shub
2011-10-26
@mon mon, you are right, I made a mistake. It should work now.
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.
mon mon
2011-10-26
2 个评论
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
2011-10-26
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!