Ask your own question, for FREE!
Mathematics 16 Online
OpenStudy (anonymous):

Help with matlab

OpenStudy (anonymous):

What help do you need?

OpenStudy (mathteacher1729):

http://www.mathworks.com/help/techdoc/index.html is always helpful. :)

OpenStudy (anonymous):

\[f(x)=x (e^-x) \cos(2x)\] write into matlab

OpenStudy (anonymous):

I have try many times but still failed

OpenStudy (mathteacher1729):

Are you STRICTLY REQUIRED to use matlab? There are far easier ways to plot functions.

OpenStudy (anonymous):

I want to make a function with that equation. But I failed to execute it.

OpenStudy (anonymous):

function y = f(x) y = x * exp(-x) * cos(2*x) try that

OpenStudy (anonymous):

OK, I'll try

OpenStudy (anonymous):

y=f(x) ??? Error using ==> power Not enough input arguments.

OpenStudy (mathteacher1729):

iwan -- are you required to use Matlab?

OpenStudy (anonymous):

f might be a protected function name. Try something else like foo. Hopefully you know how to use a function, but I'm 99% sure my code will work.

OpenStudy (anonymous):

Although I echo mathteacher. I use R predominantly. It's much quicker to use imo.

OpenStudy (phi):

You can define a function as % example matlab function function y= f(x) y= x.*exp(-x).*cos(2*x); and save it in a script as "y.m" or you can just type in the line y= x.*exp(-x).*cos(2*x); Note that the dots e.g. .* is used so this expression will work with a vector of inputs.

OpenStudy (anonymous):

the script name should be "f.m" as the function name is "f"

OpenStudy (anonymous):

OK, I got it. Now how to plot it ? for x[0.2pi]

OpenStudy (anonymous):

I mean for x[0, 2pi]

OpenStudy (phi):

x=0:0.1:2*pi; y= f(x); plot(x,y)

OpenStudy (anonymous):

OK, thanks

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!