how do you multiply f(-1)*f(0) in matlab?

조회 수: 3 (최근 30일)
Britney
Britney 2014년 10월 7일
댓글: Britney 2014년 10월 7일
Hey guys,
Annoying problem...but I'm new to matlab.
I have a function f=@(x)(x-2.5).*exp(-0.5)*(x-2).^2)+0.2. I want to calculate f(-1)*f(0). How do you do it?
I need to specify a bit. I'm confused on how to calculate f(x) for any number I want. Like, if I want the answer of f(8) of the equation how do I compute it in matlab?

채택된 답변

Image Analyst
Image Analyst 2014년 10월 7일
Try it this way:
workspace; % Make sure workspace panel is showing.
% Define function
f=@(x)(x-2.5).*exp(-0.5*(x-2).^2)+0.2
% Compute some results
r1 = f(8)
r2 = f(-1)
r3 = f(0)
r4 = r2 * r3
  댓글 수: 6
Image Analyst
Image Analyst 2014년 10월 7일
Britney, I think our answers crossed and you got it working now. So please mark the answer as Accepted if we're done.
Britney
Britney 2014년 10월 7일
if I type f(8) in command window it works. I get the same answers as Image Analyst. I think i tried typing f(8) in a different script and that is why it didn't work. But it all works now.
Thank you guys for your help!!
xoxo

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by