MATLAB: How can i display a funtion dependenet to x

matlab function

Hi How can i can i display f with values in function of x ?
L=3;
sol(1)=2;
psi=1;
f (x) = @(x) cos ( (sol(1)/L) *x)- cosh( (sol(1)/L) *x)+ psi *( sin( (sol(1)/L) *x)- sinh( (sol(1)/L) *x));

Best Answer

This works:
L=3;
sol(1)=2;
psi=1;
f = @(x) cos ( (sol(1)/L) *x)- cosh( (sol(1)/L) *x)+ psi *( sin( (sol(1)/L) *x)- sinh( (sol(1)/L) *x));
x = linspace(-10, 10);
figure(1)
plot(x, f(x))
grid
xlabel('x')
ylabel('f(x)')
See the documentation for the linspace function to understand how to change the limits and number of elements in the ‘x’ vector.