Help with matlab
What help do you need?
\[f(x)=x (e^-x) \cos(2x)\] write into matlab
I have try many times but still failed
Are you STRICTLY REQUIRED to use matlab? There are far easier ways to plot functions.
I want to make a function with that equation. But I failed to execute it.
function y = f(x) y = x * exp(-x) * cos(2*x) try that
OK, I'll try
y=f(x) ??? Error using ==> power Not enough input arguments.
iwan -- are you required to use Matlab?
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.
Although I echo mathteacher. I use R predominantly. It's much quicker to use imo.
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.
the script name should be "f.m" as the function name is "f"
OK, I got it. Now how to plot it ? for x[0.2pi]
I mean for x[0, 2pi]
x=0:0.1:2*pi; y= f(x); plot(x,y)
OK, thanks
Join our real-time social learning platform and learn together with your friends!