Info

This question is closed. Reopen it to edit or answer.

Please help me write the f function in matlab

1 view (last 30 days)
Iurie Obodeanov
Iurie Obodeanov on 7 Oct 2020
Closed: MATLAB Answer Bot on 20 Aug 2021

Answers (2)

KSSV
KSSV on 7 Oct 2020
  1. Read about sin, cos
  2. Read about exp.
  3. Read about linspace.
Example: If I want to write a function for sin(pi*x)
m = 100 ;
x = linspace(0,2,m) ;
y = sin(pi*x) ;
plot(x,y)
  2 Comments
Iurie Obodeanov
Iurie Obodeanov on 7 Oct 2020
I got to f=2.*x.*sin(6.*pi.*x+exp(2.*x.*cos(6.*pi.*x.))); but something is wrong, I don't know what
KSSV
KSSV on 7 Oct 2020
Show us the whole code which you tried....so that we cna help you.
m = 100 ; % give your value
x = linspace(0,1,m) ; % give your range for x
f=2*x.*sin(6*pi*x+exp(2*x.*cos(6.*pi*x)));
plot(x,f)
In your line..you have used x. this is not correct. You need not to use pi.*..as pi is only a single number.

James Tursa
James Tursa on 7 Oct 2020
Edited: James Tursa on 7 Oct 2020
I would assume from the equation image that the exp( ) stuff maybe should be outside of the sin( ) stuff. E.g.,
f = 2.*x.*sin(6.*pi.*x) + exp(2.*x.*cos(6.*pi.*x));

Community Treasure Hunt

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

Start Hunting!